RegExp - please help me!

szykcech at gmail.com szykcech at gmail.com
Tue Dec 26 08:14:55 EST 2017


Hi
I use online Python reg exp editor https://pythex.org/ and I use option "multiline".
I want to use my reg exp in Python script to generate automatically some part of my program written in C++ (database structure and serialization functions). In order to do this I need: 1) C++ struct name and 2) struct definition. Struct definition I need because some inline functions can appear bellow my struct definition and makes inappropriate further regexp filtering (against variables).

So: I develop regexp which to my mind should work, but it doesn't and I don't know why. The broken regexp is like this:
struct (.+)\s*{\s*(.+)\s*};
As you can see it has two groups: struct name and struct definition.
It fails even for such simple structure:
struct Structure
{
    int mVariable1;
    QString mVariable2;
    bool mVariable3
};

Please help me with this regexp or tell me that I neeed do this in other way.

thanks, happy Christmas, and happy New Year
Szyk Cech



More information about the Python-list mailing list