[英]re.sub doesn't modify string in python
I have a small python program where I expect the word "verified" (regardless if written in upper, lower case or a mix of upper and lower case). 我有一个小的python程序,希望在此使用“ verified”一词(无论是用大写,小写还是大写和小写混合编写)。 To be reset to "Verified".
重置为“已验证”。 How do I need to rewrite the code below?
我该如何重写下面的代码?
import re
text="verified, vERIFIED, VERIFIED"
text=re.sub(r'\verified', 'Verified', text, flags=re.IGNORECASE)
print text
Expected output: Verified, Verified, Verified
Actual output:verified, vERIFIED, VERIFIED
Simply remove the backslash before the v
只需在
v
之前删除反斜杠
import re
text="verified, vERIFIED, VERIFIED"
text=re.sub(r'verified', 'Verified', text, flags=re.IGNORECASE)
print text
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.