I am trying the match the following possible scenarios. They are all phone numbers but they can be from anywhere in the world.
- "92134"
- "+234234"
- "-234234"
- "234(234)"
- "(559) 559-5591 ext123"
- "(559) 559-5591 EXT123"
- "(559) 559-5591 Ext123"
- "(559) 559-5591 x123"
- "(559) 559-5591 X123"
- "416.123.4567"
Now I'm not limiting the number of digits or anything but the key problems are the following.
Allow:
- '()', '-', '.' anywhere in the string... start end e.t.c
- '+' as the first character (Doesn't need to be though)
- 'ext', 'Ex't, 'EXT', 'X', 'x' only for the last set of digits. So not (559) 559 EXt5591 EXT123
Now I have wrote the following but I do not know enough about Regex to optimize it more and get the result i want.
@"^(?=[0-9])([-.+ Ee Xx Tt \s()0-9])+$"