Regular expression bug?
Ron Garret
rNOSPAMon at flownet.com
Thu Feb 19 16:06:32 EST 2009
In article <mailman.277.1235073073.11746.python-list at python.org>,
"andrew cooke" <andrew at acooke.org> wrote:
> i wonder what fraction of people posting with "bug?" in their titles here
> actually find bugs?
IMHO it ought to be an invariant that len(r.split(s)) should always be
one more than len(r.findall(s)).
> anyway, how about:
>
> re.findall('[A-Z]?[a-z]*', 'fooBarBaz')
>
> or
>
> re.findall('([A-Z][a-z]*|[a-z]+)', 'fooBarBaz')
That will do it. Thanks!
rg
More information about the Python-list
mailing list