looking for a regular expression

Ant antroy at gmail.com
Wed Aug 2 11:33:34 EDT 2006


> But what if there's not only commas, but also periods and semicolons? I
> want to find words between 2 near by punctuations. I think it would make
> it difficult to use split instead of regular expression.

You could use re.split(r"\W", text) instead of the string split method
to split on all non-word characters.

Alternatively the regex you are looking for is probably r"\bjustice\b".




More information about the Python-list mailing list