import re
myList = ['test;cow', 'one', 'two', 'three', 'cow.', 'cow', 'acow']
myString = 'cow'
indices = [i for i, x in enumerate(myList) if re.match('\\W*' + myString +
    '\\W*', x)]
print(indices)
How do you use a regex in a list comprehension in Python?