import retexts = ['+9812345678','+99123456789']for s in texts: print(re.findall(r'^\+9[98]|\d{2}(?:\d$)?', s))
Standard input is empty
['+98', '12', '34', '56', '78'] ['+99', '12', '34', '56', '789']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!