recording data between [ and ]

Simon Brunning simon.brunning at gmail.com
Thu Apr 21 11:34:25 EDT 2005


On 4/21/05, rbt <rbt at athop1.ath.vt.edu> wrote:
> string.between(data,[,])

def between(data, start, end):
    return re.findall(re.escape(start) + r'([^]]*)'+ re.escape(end), data)
    
foo = '''stuff   [lsass.exe]
[System]  more stuff
xxxxx [firefox.exe] ......
'''

print between(foo, '[', ']')

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list