Splitting with Regular Expressions
Thomas Guettler
guettli at thomas-guettler.de
Thu Mar 17 10:12:54 EST 2005
Am Thu, 17 Mar 2005 06:51:19 -0800 schrieb qwweeeit:
> Splitting with RE has (for me!) misterious behaviour!
>
> I want to get the words from this string:
> s= 'This+(that)= a.string!!!'
>
> in a list like that ['This', 'that', 'a.string']
> considering "a.string" as a word.
Hi,
try this:
re.findall(r'[\w\.]+', s)
['This', 'that', 'a.string']
If you use r'...' you don't need to
use \\ if you mean \
\w matches a-zA-Z0-9_
\W matches all except \w
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
More information about the Python-list
mailing list