Python RE Query.
Ignacio Vazquez-Abrams
ignacio at openservices.net
Sat Sep 15 09:50:45 EDT 2001
On Sat, 15 Sep 2001, Robert Gahan wrote:
> # I am trying to create a regular expression such that if given a C
> signature, I can
> # extract all of the parameter arguements
> # e.g. for int print_date(char *date, char *month, char *year);
> # I return say the following tuple -> ("char *date", "char *month", "char
> *year")
Two things:
1) When using groups, the most recent match replaces the previous
2) Your RE is very off
Use this RE instead:
\w+\W+\**\W*\w+\(\W*(\w+\W+\**\W*\w+(\W*,\W*\w+\W+\**\W*\w+)*)\W*\);
It's not perfect, but it's much closer.
--
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list
mailing list