How to find a string inside of a string space insensitive?
This question already has an answer here:
简单:
string = 'odfsdlkfn dskfThe Moonaosjfsl dflkfn'
if 'The Moon' in string:
dosomething
you could use regular expressions:
import re
text = "odfsdlkfn dskfThe Moonaosjfsl dflkfn"
if re.find("The Moon", text):
...
and in this case, you could ingore casing with re(pattern, text, re.IGNORECASE)
if needed.
下一篇: 如何找到一个字符串空间内的字符串不敏感?