Python regular expression question

Gerrit Holl gerrit at nl.linux.org
Sun Jun 8 11:46:37 CEST 2003


DJ wrote:
> I cant figure out a re that matches a string in a sentance.
> The string can be anywhere in the sentance
> 
> eg
> 
> "dog"
> 
> I walked my dog today

You don't need re's!

You can simply do:

line.index("dog")
http://www.python.org/dev/doc/devel/lib/string-methods.html

Or, with Python 2.3, even more simple:

"dog" in line
http://www.python.org/doc/2.3b1/whatsnew/node17.html

yours,
Gerrit.

-- 
183. If a man give his daughter by a concubine a dowry, and a husband,
and a deed; if then her father die, she shall receive no portion from the
paternal estate.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list