I am looking to use regex to extract text which occurs between two strings. I know how to do if i want to extract between the same strings every time (and countless questions asking for this e.g. Regex matching between two strings?), but I want to do it using variables which change, and may themselves include special characters within Regex. (i want any special characters, e.g. * treated as text).
For example if i had:
text = "<b*>Test</b>"
left_identifier = "<b*>"
right_identifier = "</b>
i would want to create regex code which would result in the following code being run:
re.findall('<b\*>(.*)<\/b>',text)
It is the <b\*>(.*)<\/b>
part that I don't know how to dynamically create.