+ 2
How to put input into pattern of regex(plain string) ?
I want to have a search function(with regex) which will take input from user and search the input through a content(any text).
2 Réponses
+ 7
You can take an input like "[0-9]" (do not enter the quotes !) and store it in a variable like "pattern". then use this variable in your regex call like:
if re.search(pattern, password):
....
+ 1
Lothar thanks man. I was wrong to think that pattern must be smthing like this:
pattern = r"smthing"
This is possible:
pattern = input()