This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josiahcarlson
Recipients
Date 2004-10-30.15:44:33
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=341410

In the case of this particular search, you could write your
own little searcher.  The following could likely be done
better, but this is a quick 5-minute job that won't core on
you unless something is really wrong with Python, and may be
a reasonable stopgap until someone re-does the regular
expression library.

import string

def find_thing(s):
    sp = 0
    d = dict.fromkeys(list(string.letters+string.digits+'_'))
    while sp < len(s):
        start = None
        for i in xrange(sp, len(s)):
            if s[i] == '[':
                start = i
                break
        if start is None:
            return
        for i in xrange(start+1, len(s)):
            if s[i] in d:
                continue
            elif s[i] == ']':
                return s[start:i+1]
            else:
                sp = i
                break

It returns None on failure to find, and the string otherwise.
History
Date User Action Args
2007-08-23 14:27:04adminlinkissue1054564 messages
2007-08-23 14:27:04admincreate