Regex Group case change

Raju ch.nagaraju008 at gmail.com
Thu Oct 1 15:41:25 EDT 2020


Hello Everyone,

I want to change the case on input string i was able to match using python regex but couldn't find the way to change the case.

For example string: 
Input: 7Section Hello Jim 
output: 7Section hello Jim

I was doing if statment with regex

if re.match("(\d+\w* )(Hello)( \w+)",string)):
   print(r"(\d+\w* )(Hello)( \w+)","\1\2.lower()\3",string)

Output was
7Section \2.lower() Jim
Above one is one of the regex i have in function, i have total 6 regex patterns and i want to keep all in this if elif else statment. It is matching, but can someone advise how to replace Hello to hello?

Thanks


More information about the Python-list mailing list