Insanity
Tim Daneliuk
tundra at tundraware.com
Sun Jan 23 13:58:20 EST 2005
Fredrik Lundh wrote:
> Tim Daneliuk wrote:
>
>
>>Thanks - very helpful. One followup - your re works as advertised. But
>>if I use: r'\[PROMPT:[^]].*\]' it seems not to. the '.*' instead of just '*'
>>it matches the entire string ...
>
>
> it's not "just '*'", it's "[^]]*". it's the "^]" set (anything but ]) that's repeated.
>
> "[^]].*\]" means match a single non-] character, and then match as many
> characters as you possibly can, as long as the next character is a ].
>
> "[^]]*\]" means match as many non-] characters as possible, plus a single ].
Got it - 'Makes perfect sense too
>
>
>>which seems counterintutive to me.
>
>
> then you need to study RE:s a bit more.
>
> (hint: an RE isn't a template, it's a language description, and the RE engine
> is designed to answer the question "does this string belong to this language"
> (for match) or "is there any substring in this string that belongs to this
> language" (for search) as quickly as possible. things like match locations
> etc are side effects).
Yes, I understand this. But your clarification is most helpful. Thanks!
----------------------------------------------------------------------------
Tim Daneliuk tundra at tundraware.com
PGP Key: http://www.tundraware.com/PGP/
More information about the Python-list
mailing list