I will remove leading whitespace then just below (except that 12345.. means [0-9]{1,10}
they want to allow
' ext. 12345 '
'ext 123456789'
' Ext. 1234567 '
'Ext 1234'
'x123456'
I thought this would do it..
(x{1}|ext{1}|ext\.{1}|Ext{1}|Ext\.{1})\s*[0-9]{1,}
BILL Carlisle
ASKER
Here, I tweaked it because you gave me this cool tool!
(?:\s*(?:x|ext\.?)\s*(\d{1,10})+)?
But now I want to exclude this one
ext. 5t64564
I want the digits to be the last part of the input.. no extra chars
I only want it to match those patterns. only is a + sign ?
SSupreme
It already does what you want, not sure what you are doing.
just add ^ at start and $ at the end. Like this.
^(?:\s*(?:x|ext\.?)\s*(\d{1,10})+)?$
Use "Unit tests" to create tests and test with real values, my list in "Test string" doesn't make any sense as there are many stringS, it just for personal preview that it works.
Why doesn't the tool match any with that?
^(?:\s*(?:x|ext\.?)\s*(\d{1,10})+)?$
I tried
^(x|ext\.?\s)?[0-9]{3,10}$ in the tool but doesn't match anything.
tried this in the console and worked great.. (except for matching Ext and Ext.)
var myExp = /^(x|ext\.?\s)?[0-9]{3,10}$/;
if (myExp.test("ext. 123")){
console.log('true');
}else{
console.log('false');
}
BILL Carlisle
ASKER
Use "Unit tests" to create tests and test with real values, my list in "Test string" doesn't make any sense as there are many stringS, it just for personal preview that it works.
Have a look.