I am trying to write regex expression in python.
For the following text:
9430 123 12345
5322 123 12345
3441 123 12345
I need to extract only the two line that begin with 5322 and 9430. All other codes should be ignored. I used the following expression:
patfinder1 = re.compile('((5322|9430))(\s\d{3}\s\d{5})')
patsearch = re.findall(patfinder1, search_str)
but is giving me too many matches in place of getting the two lines result:
('9430', '9430', ' 123 12345')
('5322', '5322', ' 123 12345')
I also tried many different expressions but still did not find the right one.