The Python Oracle

How to use a variable inside a regular expression?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Realization

--

Chapters
00:00 Question
00:23 Accepted answer (Score 205)
02:47 Answer 2 (Score 336)
03:09 Answer 3 (Score 53)
03:24 Answer 4 (Score 41)
03:35 Thank you

--

Full question
https://stackoverflow.com/questions/6930...

Accepted answer links:
[Literal String Interpolation]: https://www.python.org/dev/peps/pep-0498/
[here]: https://docs.python.org/3/howto/regex.ht...
[here]: https://docs.python.org/3/library/re.htm...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #regex #python3x #variables #escaping

#avk47