Python Используйте переменную в выражении коррекса
# Short answer:
# The regex expression is a string which can be built up like any string in
# Python
# Example usage:
import re
your_string = 'Your string to search'
variable = 'ring'
re.search('.+' + variable + '.+', your_string) # or:
re.search('.+{}.+'.format(variable), your_string)
Charles-Alexandre Roy