[Solved] Extracting using a string pattern in Regex- Python


Use (.*)(?:Bangalore) pattern

>>> line = ("Kathick Kumar, Bangalore who was a great person and lived from 29thMarch 1980 - 21 Dec 2014")
>>> import re
>>> regex = re.compile('(.*)(?:Bangalore)')
>>> result = regex.search(line)
>>> print(result.group(0))
Kathick Kumar, Bangalore
>>> 

1

solved Extracting using a string pattern in Regex- Python