I'm trying to get a string between one or more pairs of string. For example,
import re
string1 = 'oi sdfdsf a'
string2 = 'biu serdfd e'
pattern = '(oi|biu)(.*?)(a|e)'
substring = re.search(pattern, string1).group(1)
In this case I should get: "sdfdsf" if I use string1 and "serdfd" if I use string2 in the search funnction. Instead I'm getting "oi" or "biu"
str.split?.group(2)to get it. Just.strip()it afterwards, no need to complicate the regex.