Re: Problem with regular expression

2010-03-07 Thread Paul McGuire
On Mar 7, 4:32 am, Joan Miller wrote: > I would to convert the first string to upper case. But this regular > expression is not matching the first string between quotes. > Is using pyparsing overkill? Probably. But your time is valuable, and pyparsing let's you knock this out in less time than i

Re: Problem with regular expression

2010-03-07 Thread Tim Chase
Joan Miller wrote: I would to convert the first string to upper case. But this regular expression is not matching the first string between quotes. re.sub("'(?P\w+)': [^{]", "\gFOO", str) Well, my first thought is that you're not using raw strings, so you're not using the regexps and replace

Re: Problem with regular expression

2010-03-07 Thread Steve Holden
Joan Miller wrote: > I would to convert the first string to upper case. But this regular > expression is not matching the first string between quotes. > > re.sub("'(?P\w+)': [^{]", "\gFOO", str) > > # string to non-matching > 'foo': { > > # strings to matching > 'bar': 'bar2' > 'bar': None > '

Re: Problem with regular expression

2010-03-07 Thread News123
Hi Joan, Joan Miller wrote: > I would to convert the first string to upper case. But this regular > expression is not matching the first string between quotes. > > re.sub("'(?P\w+)': [^{]", "\gFOO", str) > > # string to non-matching > 'foo': { > > # strings to matching > 'bar': 'bar2' > 'ba