[Solved] Python re: how to lowercase some words [closed]


Wanted solution using regex, here you are:

>>> import re
>>> s = "StringText someText Wwwwww SomeOtherText OtherText SOMETextMore etc etc etc"
>>> def replacement(match):
...   return match.group(1).lower()
>>> re.sub(r'([sS]\w+)', replacement, s)
'stringtext sometext Wwwwww someothertext OtherText sometextmore etc etc etc'

10

solved Python re: how to lowercase some words [closed]