[Tutor] Regexes -- \b ; re.sub
John Abbe
johnca@ourpla.net
Sat Nov 16 04:15:02 2002
Can someone explain to me why this...
import re
matches = re.search (re.compile ("(.)\b(.)"), "spam and eggs are yummy")
if matches:
print matches.groups()
else:
print "no match"
...prints out "no match", and this...
print re.sub (re.compile ("(i)"), "o\1o", "i like eggs and spam")
...prints out "oo looke eggs and spam" -- shouldn't it be "oio loioke
eggs and spam", after all this...
print re.search (re.compile ("(i)"), "i like eggs and spam").group(1)
...prints out "i"
Mucho thanks...Life,
John
--
All you /\/\ John Abbe "If you don't like the news,
need \ / CatHerder go out and make some of your own."
is... \/ http://www.ourpla.net/john/ --Wes Nisker