Saturday, 14 September 2013

Regex MULTILINE not working?

Regex MULTILINE not working?

In the example module below. The pattern only matches the first part of
the string. How to make it match and display all the substrings matching
the pattern?
filtered ='\n\rweakmoves (1835) seeking 5 0 unrated blitz ("play 89" to
respond)\n\r\n\rGuestKCCZ (++++) seeking 15 0 unrated standard ("play 91"
to respond)\n\r\n\rGuestKKKP (++++) seeking 3 0 unrated blitz f ("play
59" to respond)\n\r'
rgxseeking
=re.compile(r'^\S+\s\(([\d+-]+)\)\s+seeking\s+(\d+\s\d+)\s+(\S{1,7})\s(\S{1,9})(\s\[\S+\])?((\s[fm])?)((\s[fm])?)\s\("play\s\d{1,3}\"\sto\srespond\)$',re.MULTILINE)
seeking= re.search(rgxseeking,filtered)
if seeking:
print seeking.group()

No comments:

Post a Comment