[Tutor] Why doesn't this regex match???
Sat, 9 Feb 2002 09:43:31 -0500
On Fri, Feb 08, 2002 at 11:26:53PM -0800, Sheila King wrote:
> So I tried the following, with the dismal results shown. Now what am I
> doing wrong?
> >>> searchstring = 'ADV: FREE FREE OFFERZ!!!!'
> >>> word = 'adv:'
> >>> p = re.compile(r'[\b\A\s]%s[\b\Z\s]' % word, re.I)
'' says 'any one *character* from the set'. '\b', '\A', and '\Z' are
p=re.compile(r'\b%s\b' % word, re.I) ought to do what you want.
'word boundary' includes 'white space before and after' and 'beginning
and end of string'.
"Once the principle of government -- judicial monopoly and the power
to tax -- is incorrectly accepted as just, any notion of restraining
government power and safeguarding individual liberty and property is
illusory." -- Hans-Herman Hoppe
Rick Pasotto firstname.lastname@example.org http://www.niof.net