Python re.sub(): how to substitute all 'u' or 'U's with 'you'

后端 未结 5 1101
暖寄归人
暖寄归人 2021-01-30 03:19

I am doing some text normalization using python and regular expressions. I would like to substitute all \'u\'or \'U\'s with \'you\'. Here is what I have done so far:

         


        
5条回答
  •  离开以前
    2021-01-30 03:56

    Another possible solution I came up with was:

    re.sub(r'([uU]+(.)?\s)',' you ', text)
    

提交回复
热议问题