[Tutor] Regular expression oddity
Emmanuel Ruellan
emmanuel.ruellan at laposte.net
Sun Nov 23 00:44:21 CET 2008
Hi tutors!
While trying to write a regular expression that would split a string
the way I want, I noticed a behaviour I didn't expect.
>>> re.findall('.?', 'some text')
['s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't', '']
Where does the last string, the empty one, come from?
I find this behaviour rather annoying: I'm getting one group too many.
Regards,
Emmanuel
More information about the Tutor
mailing list