Diez B. Roggisch deets at
Wed Jun 4 20:07:41 CEST 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 = """
foo disc bar

for t in test:
     if"(^|[^\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.


More information about the Python-list mailing list