Re: string find/replace

2010-12-02 Thread Piet van Oostrum
Carlo writes: > On 2010-12-01, Peter Otten <__pete...@web.de> wrote: > import re > re.compile("([a-z])([A-Z])").sub(r"\1 \2", "camelCase") >> 'camel Case' > > Very simple if you know it. Thank you! And almost as cryptic as Perl!! -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP

Re: string find/replace

2010-12-01 Thread MRAB
On 01/12/2010 17:36, Carlo wrote: Hello, I want the Python equivalent of the Perl expression: s/([a-z])([A-Z])/\1 \2/g In plain language: place a space between a lowercase and uppercase letter. I get lost in the RE module. Can someone help me? That's easy: new_text = re.sub(r'([a-z])([A-Z

Re: string find/replace

2010-12-01 Thread Carlo
On 2010-12-01, Peter Otten <__pete...@web.de> wrote: import re re.compile("([a-z])([A-Z])").sub(r"\1 \2", "camelCase") > 'camel Case' Very simple if you know it. Thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: string find/replace

2010-12-01 Thread Donald O'Donnell
On Dec 1, 12:36 pm, Carlo wrote: > Hello, > > I want the Python equivalent of the Perl expression: > s/([a-z])([A-Z])/\1 \2/g > In plain language: place a space between a lowercase and uppercase > letter. I get lost in the RE module. Can someone help me? > > Thanks! This will also replace '_' wit

Re: string find/replace

2010-12-01 Thread Peter Otten
Carlo wrote: > I want the Python equivalent of the Perl expression: > s/([a-z])([A-Z])/\1 \2/g > In plain language: place a space between a lowercase and uppercase > letter. I get lost in the RE module. Can someone help me? >>> import re >>> re.compile("([a-z])([A-Z])").sub(r"\1 \2", "camelCase")

string find/replace

2010-12-01 Thread Carlo
Hello, I want the Python equivalent of the Perl expression: s/([a-z])([A-Z])/\1 \2/g In plain language: place a space between a lowercase and uppercase letter. I get lost in the RE module. Can someone help me? Thanks! -- http://mail.python.org/mailman/listinfo/python-list