Message22868
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. |
|
Date |
User |
Action |
Args |
2007-08-23 14:27:04 | admin | link | issue1054564 messages |
2007-08-23 14:27:04 | admin | create | |
|