samedi 18 avril 2015

Python regex - wierd behavior - findall doesnt match regex101

I need to extract some functions from files.


I have this code:



pattern = "^\s*[a-zA-Z_]?.*void\s+[a-zA-Z_][a-zA-Z_0-9]*\s*\((?s).*?\).*?$"
objekt = re.findall(re.compile(pattern,re.MULTILINE), string)


where string is



extern inline void
lineBreak ( void )

;


extern inline void debugPrintf
(
const int level,
const char * const format,
...)
{
return NULL;
}

extern void
debugPutc
(
const int level
,
const int c)
;


it returns however



extern inline void
lineBreak ( void )

;


extern inline void debugPrintf
(
const int level,
const char * const format,
...)
{
return NULL;
}

extern void
debugPutc
(
const int level
,
const int c)


while when I am debugging at regex101 it returns 3 functions that I need to extract.


regex101 demo


Does anyone know where is the problem please? Thank you.


Aucun commentaire:

Enregistrer un commentaire