Python match a string with regex
Question: I need a python regular expression to check if a word is present in a string.
The string is separated by commas, potentially.

So for example,

    
    
    line = 'This,is,a,sample,string'
    

I want to search based on "sample", this would return true. I am crappy with
reg ex, so when I looked at the python docs, I saw something like

    
    
    import re
    re.match(r'sample', line)
    

But I don't know why there was an 'r' before the text to be matched. Can
someone help me with the regular expression?


Answer: Are you sure you need a regex? It seems that you only need to know if a word
is present in a string, so you can do:

    
    
    >>> line = 'This,is,a,sample,string'
    >>> "sample" in line
     True
    

