regex help for a newbie
marco
marco at reimeika.ca
Tue Apr 6 17:23:32 EDT 2004
Marco Herrn <herrn at gmx.net> writes:
> On 2004-04-06, marco <marco at reimeika.ca> wrote:
> > Marco Herrn <herrn at gmx.net> writes:
> >> the parts in a recursive function. So the thing I want to achieve here
> >> is to extract %(BBB%(CCC)BBB) and %(DDD).
> >
> > p1, p2 = "aaa%(BBB%(CCC)BBB)aaa%(DDD)aaa".split("aaa")[1:-1]
>
> Doesn't help, since I do not know that there is the string "aaa". It was
> just an example. I do not know any of the strings/characters. The only
> thing I know is that a percent sign indicates that the content inside
> the following parentheses is an expression that has to be evaluated.
Ah, that's clearer ;)
Does the "aaa"-type string really show up three times? Or is it actually:
"maybeeggs%(BBB%(CCC)BBB)maybeham%(DDD)maybespam"
If it's like you describe then maybe:
"aaa%(BBB%(CCC)BBB)aaa%(DDD)aaa".split("aaa%(BBB%(CCC)BBB)aaa%(DDD)aaa".split("%(")[0])[1:-1]
helps (but I doubt it -- I guess you'll need a real parser :)
Cheers,
--
marco at reimeika.ca
Gunnm: Broken Angel http://amv.reimeika.ca
http://reimeika.ca/ http://photo.reimeika.ca
More information about the Python-list
mailing list