regex question

Gabriel Murray gabriel.murray at gmail.com
Thu Aug 3 17:10:55 EDT 2006


Hello, I'm looking for a regular expression which will match strings as
follows: if there are symbols a, b, c and d, then any pattern is valid if it
begins with a and ends with d and proceeds in order through the symbols.
However, at any point the pattern may reset to an earlier position in the
sequence and begin again from there.
For example, these would be valid patterns:
aabbbaabbcccbbbcccddd
aabcabcd
abcd

But these would not:
aaaaabbbbbccccaaaaadddd   (goes straight from a to d)
aaaaaaaaaaabbbbbccc (does not reach d)

Can anyone think of a concise way of writing this regex? The ones I can
think of are very long and awkward.
Gabriel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060803/326825de/attachment.html>


More information about the Python-list mailing list