If a string contains *SUBJECT123
how to determine that the string has subject
in it in python
views:
63answers:
4Is it case insensitive?
Rajeev
2010-07-28 08:54:55
you can use the lower() method
ghostdog74
2010-07-28 09:14:36
+1
A:
If you want to have subject
match SUBJECT
, you could use re
import re
if re.search('subject', your_string, re.IGNORECASE)
Or you could transform the string to lower case first and simply use:
if "subject" in your_string.lower()
Felix Kling
2010-07-28 08:51:36
A:
if "*SUGJECT123" in mystring and "subject" in mystring:
# do something
Douglas Leeder
2010-07-28 08:52:44
A:
Just another way
mystring.find("subject")
the above answers will return true if the string contains "subject" and false otherwise. While find will return its position in the string if it exists else a negative number.
anand
2010-07-28 08:55:02