I have written 2 REs to match several string sequences in a String. for e.g. lets assume the two regular expressions are RE1
, RE2
. The strings can be i
You need to escape the \ in the second RE:
RE1 = '(\d{1,3}[a-zA-Z]?/\d{1,3}[a-zA-Z]?)'
RE2 = '(\\babc\\b)'
s = '*some string* 100/64h *some string* 120h/90 *some string* abc 200/100 abc *some string* 100h/100f'
p = re.compile('('+RE2+'|'+RE1+')');
matches = p.findall(s)
for match in matches:
print(match[0])