Problem with regular expression

News123 news123 at free.fr
Sun Mar 7 07:52:13 EST 2010


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<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'
> 
I'm a little slow today and don't exactly understand your question.

Could you perhaps add some examples of input lines and what you would
like to extract?

example:
input = "first word to Upper"
output = "FIRST word to Upper"


bye


N

> 
> Any help? please
> Thanks in advance



More information about the Python-list mailing list