OT: regular expression matching multiple occurrences of one group
Diez B. Roggisch
deets at nospam.web.de
Mon Nov 9 10:46:58 EST 2009
pinkisntwell schrieb:
> How can I make a regular expression that will match every occurrence
> of a group and return each occurrence as a group match? For example,
> for a string "-c-c-c-c-c", how can I make a regex which will return a
> group match for each occurrence of "-c"?
Why is this flagged "OT"?
And in python, you can't do that. Groups are based upon the lexical
structure of the regexp, and thus have a fixed number of groups.
Either use repetitive searches over the input, or postprocess the
combined group by e.g. splitting it.
Diez
More information about the Python-list
mailing list