I am fairly new to python, and really new to regex!
I am using the re module in python and trying to insert a variable into a re.compile statement.
I have a file that includes these words as test – linux windows mac –
So if I do re.compile('...u.', re.IGNORECASE) it will find linux.
But how to I put ...u. into a variable to use in the re.compile? Just assigning '...u.' to a variable and putting that in place of it in the re.compile does not seem to work.
I found on another thread something about the % character, but could not get that to work.
Any help is greatly appreciated!
Could you show your code snippet for “assigning
'...u.'to a variable”?It works for me: