Match First Sequence in Regular Expression?
Roger L. Cauvin
roger at deadspam.com
Thu Jan 26 14:05:04 EST 2006
"Tim Chase" <python.list at tim.thechases.com> wrote in message
news:mailman.1093.1138297753.27775.python-list at python.org...
> The below seems to pass all the tests you threw at it (taking the modified
> 2nd test into consideration)
>
> One other test that occurs to me would be
>
> "xyz123aaabbaaabab"
>
> where you have "aaab" in there twice.
Good suggestion.
> ^([^b]|((?<!a)b))*aaab+[ab]*$
Looks good, although I've been unable to find a good explanation of the
"negative lookbehind" construct "(?<". How does it work?
--
Roger L. Cauvin
nospam_roger at cauvin.org (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com
More information about the Python-list
mailing list