I have a large number of BASIC source-code files I want to scan and 
replace certain parts of text.  To complicate things, there are three 
strings I need to match, and I'm really only interested in the numbers 
(1 to 63) which come at the end of the string.  The search-replace 
script I am writing is being done in Python.

Individually the following regexs work:
(?i)\bMbeSettings\.level *= *(\d\d?\b)
(?i)\bActive level (\d\d?\b)
(?i)\blv *= *(\d\d?\b)

BUT if I try combining them to something like this:
(?i)(?:\bMbeSettings\.level *= *(?P<ln>\d\d?\b))|
(?:\bActive level (?P=ln))|
(?:\blv *= *(?P=ln))

NOTE: I deliberately linewrapped this after the '|' for this email,
it's one long line in the script.
Also, I've tried:
Not using named groups and 'undelimited' groups, and
Having the numeral group listed once, at the end of the regex after
 having another group of the other text 'or'ed together at the start.

Am I just punishing my brain and the regex module by trying to make 
one encompassing beast?
Can anyone point out where I went wrong?

Examples of what I'm trying to match would be
Active level 20
lv=20
lv = 20
Mbesettings.level=20
Mbesettings.level = 20

And all i want to do is replace the '20' with another string.

thanks all
Steve
-- 
"We live in an age of continuous partial attention."
--Ms. Linda Stone, researcher and VP at Microsoft

http://www.helmsdeep.net/capn-k/
Linux | Windows | CAD | Audio Visualisation and more







-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to