+ 2

Regex pattern as user input

How can i manage to give a pattern to my program, as user input? I try to give: ^[A-Z][a-z]+\s\d+\.\d but it does not work with the ^ sign. whyyyyyyy???

24th Jan 2018, 5:46 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar
2 Respostas
0
are you using raw_input() ?
24th Jan 2018, 6:14 PM
Vincent
Vincent - avatar
0
i use python 3, and there is no raw_ input, google says, that input() does the same. I try to use pattern = input(), or pattern = re.compile("{0}".format(input(pattern)) ,not sure, it does the same. i dont know how to put the user input in r'pattern'.
24th Jan 2018, 6:36 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar