[Tutor] regular expression question
nihilo
exnihilo at myrealbox.com
Sun Aug 31 10:46:26 EDT 2003
hi,
I'm stuck on a regular expression. I want to match everything starting from a word up to and including the next occurence of the word.
If the word were a single character (say 'a'), then I could do the following:
pat = re.compile('a[^a]*a')
The problem is that I haven't been able to find out how to exclude the word if it is more than one character. [^word] excludes the individual letters, not the word as a whole, and I tried grouping with braces and parentheses [^(word)], but these don't work. I've checked many re tutorials, and they all say how to exclude a single character from the set of characters inside the brackets, but not how to exclude more than 1 character.
thanks for any help or pointers to resources...
More information about the Tutor
mailing list