regex help for a newbie

Marco Herrn herrn at gmx.net
Tue Apr 6 18:38:24 EDT 2004


On 2004-04-06, marco <marco at reimeika.ca> wrote:
> 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.
>
> Does the "aaa"-type string really show up three times? Or is it actually:
>
> "maybeeggs%(BBB%(CCC)BBB)maybeham%(DDD)maybespam"

Yes, it is this. I just used the same strings to indicate the nesting
levels. All strings in this expression are arbitrary strings.

> (but I doubt it -- I guess you'll need a real parser :)

Yes, I already realized that :-)

Marco

-- 
Marco Herrn             herrn at gmx.net
(GnuPG/PGP-signed and crypted mail preferred)
Key ID: 0x94620736




More information about the Python-list mailing list