re
Diez B. Roggisch
deets at nospam.web.de
Wed Jun 4 14:07:41 EDT 2008
> Whitespace is actually \s. But [\s]disc[whatever]
> doesn't do the job - then it won't match "(disc)",
> which counts as "disc appearing as a full word.
Ok, then this works:
import re
test = """
disc
(disc)
foo disc bar
discuss
""".split("\n")
for t in test:
if re.search(r"(^|[^\w])(disc)($|[^\w])", t):
print "success:", t
> Also I think you have ^ and $ backwards, and there's
> a ^ I don't understand. I _think_ that a correct version
Yep, sorry for the confusion.
Diez
More information about the Python-list
mailing list