Regular expression bug?
Ron Garret
rNOSPAMon at flownet.com
Thu Feb 19 16:03:59 EST 2009
In article <gnkdal$bcq$01$1 at news.t-online.com>,
Peter Otten <__peter__ at web.de> wrote:
> Ron Garret wrote:
>
> > I'm trying to split a CamelCase string into its constituent components.
>
> How about
>
> >>> re.compile("[A-Za-z][a-z]*").findall("fooBarBaz")
> ['foo', 'Bar', 'Baz']
That's very clever. Thanks!
> > (BTW, I tried looking at the source code for the re module, but I could
> > not find the relevant code. re.split calls sre_compile.compile().split,
> > but the string 'split' does not appear in sre_compile.py. So where does
> > this method come from?)
>
> It's coded in C. The source is Modules/sremodule.c.
Ah. Thanks!
rg
More information about the Python-list
mailing list