Is it possible to use an input() with regex
I've written something like this
import re
words = ['cats', 'cates', 'dog', 'ship']
for l in words:
m = re.search( r'cat..', l)
if m:
print l
else:
print 'none'
this will return 'cates'
But now I want to be able to use my own input()
in ' m = re.search( r'cat..', l)
'
something like
import re
words = ['cats', 'cates', 'dog', 'ship']
target = input()
for l in words:
m = re.search( r'target..', l)
if m:
print l
else:
print 'none'
this doesn't work of course (I know it will search for the word 'target' and not for the input()). Is there a way to do this or are'nt regular expressions not the solution for my problem?