Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
(?i)\s*((?:Ext|Ex|X(?<!FAX))[- .]*\d{1,4}(?![-\d]))
"
g
Input 1
New
From the pattern I have right now i can match on numbers like Ext. 115, X 256, Ex 2114 only when no other numbers are present. However when a phone number is present I'll match that first or when a fax is indicated from the string "Jane Doe 888-888-8888/Fx 888-8888 ill match on x 888-8888. Input strings "Jane EXT. 115", "Jane X289 FAX 888-888-8888", "John Doe-X 241 OR CELL888/8888888" Output is "EXT. 115", "X289", "X 241" Other input I have is "Jane Doe 888-888-8888", "John Doe FX 888-888-8888" which matches on "e 888-888-8888", and "X 888-888-8888" when there is no extension present
Extraction
From the pattern I have right now i can match on numbers like Ext. 115, X 256, Ex 2114 only when no other numbers are present. However when a phone number is present I'll match that first or when a fax is indicated from the string "Jane Doe 888-888-8888/Fx 888-8888 ill match on x 888-8888. Input strings "Jane EXT. 115", "Jane X289 FAX 888-888-8888", "John Doe-X 241 OR CELL888/8888888" Output is "EXT. 115", "X289", "X 241" Other input I have is "Jane Doe 888-888-8888", "John Doe FX 888-888-8888" which matches on "e 888-888-8888", and "X 888-888-8888" when there is no extension present