RegExp - please help me!
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
--
https://mail.python.org/mailman/listinfo/python-list
Re: RegExp - please help me! (Posting On Python-List Prohibited)
W dniu wtorek, 26 grudnia 2017 21:53:14 UTC+1 użytkownik Lawrence D’Oliveiro napisał: > On Wednesday, December 27, 2017 at 2:15:21 AM UTC+13, [email protected] wrote: > > struct (.+)\s*{\s*(.+)\s*}; > > You realize that “.” matches anything? Whereas I think you want to match > non-whitespace in those places. I realize that. I want skip white-spaces from the beginning and from the end and match entire body of C++ struct declaration (with white spaces inside as well). Maybe should I use "".strip(" ").strip("\t").strip("\n") function after matching? -- https://mail.python.org/mailman/listinfo/python-list
Re: RegExp - please help me!
> (?s)struct (.+?)\s*\{\s*(.+?)\s*\};
Thank you Vlastimil Brom for regexp and for explanation!
--
https://mail.python.org/mailman/listinfo/python-list
