If a string contains *SUBJECT123, how do I determine that the string has subject in it in python?
-
What is the relevance of "If a string contains *SUBJECT123"? Do you mean "How do I do a case-insensitive search"?John Machin– John Machin2010-07-28 08:59:30 +00:00Commented Jul 28, 2010 at 8:59
Add a comment
|
4 Answers
if "subject" in mystring.lower():
# do something
1 Comment
ghostdog74
you can use the lower() method
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()