Hope you are looking something like this,
import re
pattern = r'\d+\s+-\s+\d+\s+yrs'
text="card_travel2 - 3 yrslocation_onKolkata"
re.findall(pattern, text)
output
['2 - 3 yrs']
9
solved Python Regular Expression getting sub string [closed]
Hope you are looking something like this,
import re
pattern = r'\d+\s+-\s+\d+\s+yrs'
text="card_travel2 - 3 yrslocation_onKolkata"
re.findall(pattern, text)
output
['2 - 3 yrs']
9
solved Python Regular Expression getting sub string [closed]