Python regular expression question!
Hallvard B Furuseth
h.b.furuseth at usit.uio.no
Wed Sep 20 13:02:38 EDT 2006
"unexpected" <sumesh.chopra at gmail.com> writes:
> I'm trying to do a whole word pattern match for the term 'MULTX-'
>
> Currently, my regular expression syntax is:
>
> re.search(('^')+(keyword+'\\b')
\b matches the beginning/end of a word (characters a-zA-Z_0-9).
So that regex will match e.g. MULTX-FOO but not MULTX-.
Incidentally, in case the keyword contains regex special characters
(like '*') you may wish to escape it: re.escape(keyword).
--
Hallvard
More information about the Python-list
mailing list