On Thu, 03 Aug 2006 22:10:55 +0100
Gabriel Murray <[EMAIL PROTECTED]> wrote:

#> Hello, I'm looking for a regular expression ....

  Some people, when confronted with a problem, think "I know, I'll
  use regular expressions." Now they have two problems.
                                   -- Jamie Zawinski

Therefore:

def test(data):
    format, index = 'abcd', 0
    for c in data:
        i = format.index(c)
        if i > index+1:
            return False
        index = i
    return index==format.index('d')

Could be made faster if format was made a dictionary or if one wanted
to compare characters directly. Writing (and profiling) left as an
exercise for a reader.

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( [EMAIL PROTECTED] )

A mind is like a parachute. It doesn't work unless it's open.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to