Problem with regular expression

Joan Miller peloko45 at gmail.com
Sun Mar 7 05:32:28 EST 2010


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<id>\w+)': [^{]", "\g<id>FOO", str)

# string to non-matching
'foo': {

# strings to matching
'bar': 'bar2'
'bar': None
'bar': 0
'bar': True

So, i.e., from the first string I would to get:
  'BAR': 'bar2'


Any help? please
Thanks in advance



More information about the Python-list mailing list