[Solved] Defining regular expression
[ad_1] I would use findall for this.. >>> import re >>> s=”AN : GSHJ488GL67 Customer : sh3893 Acnt No : cgk379gu Name : xyz” >>> re.findall(r’\b(?:AN|Acnt No) : (\w+)’, s) [‘GSHJ488GL67’, ‘cgk379gu’] Explanation: \b # the boundary between a word character and not a word character (?: # group, but do not capture: AN # … Read more