I am using regex to extract acronyms(only specific types) from text in python.
- ABC (all caps within round brackets or square brackets or between word endings)
- A.B.C (same as above but having only one '.' in between)
- A&B&C (same as above but having only one '&' in between)
So far I am using
text = "My name is STEVE. My friend works at (I.A.). Indian Army(IA). B&W also B&&W Also I...A"
re.findall('\\b[A-Z][A-Z.&]{2,7}\\b', text)
Output is : ['STEVE', 'I.A', 'B&W', 'B&&W', 'I...A']
I want to exclude B&&W and I..A, but include (IA).
I am aware of the below links but I am unable to use them correctly. Kindly help.
Extract acronyms patterns from string using regex