This question already has answers here:
Get price value from a string
(7 answers)
Closed 3 years ago.
I am trying to extract number from title. I have title like this:
**
Apartment London, 230.400€, 450,00m2
**
I want to extract only this price number (230.400€), can anybody help me with this?
So far my code look like this
\d+\.?\d+(.)
You can include the amount symbol as part of your RegEx:
/\d+\.?\d+(.)€/
Or you can try using Positive lookahead:
\d+\.?\d+(.)(?=€)
This question already has answers here:
How to validate phone numbers using regex
(43 answers)
Closed 6 years ago.
I found a pretty old example but it's almost doing exactly what i need to do:
Auto Dash using Javascript on FOCUS (for a telephone number format)
However instead of the current format xxx-xxx-xxxx i'd like to do (xxx) xxx-xxxx
Can someone give me a hand with the script below with this??
$('.telnumber').keyup(function() {
this.value = this.value
.match(/\d*/g).join('')
.match(/(\d{0,3})(\d{0,3})(\d{0,4})/).slice(1).join('-')
.replace(/-*$/g, '');
console.log("this value", this.value);
});
You could do something like this
var a = this.value.match(/\d*/g).join('')
.match(/(\d{0,3})(\d{0,3})(\d{0,4})/).slice(1);
this.value = ['(',a[0],') ',a[1],'-',a[2]].join('');
It's not very elegant but hey, elegance is for tailors right?
Update
Yea, I got bored and made a one-liner, here:
this.value = '('+this.value
.match(/\d*/g).join('')
.match(/(\d{0,3})(\d{0,3})(\d{0,4})/).slice(1)
.map((a,i)=>(a+[') ','-',''][i])).join('');
The code you'll want to change is .join('-'). That's where you're getting the 'xxx-xxx-xxxx' from.
You need to tokenize those 3 regular expressions and then join them separately.
This question already has answers here:
How to validate phone numbers using regex
(43 answers)
Closed 8 years ago.
Can somebody give me the regex for validating the phone numbers 000.0000.000000 and also without the dots.
sample numbers
880.1817.087511
and
8801817087511
try this.
\b\d{3}[.]?\d{4}[.]?\d{6}\b
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Phone Number Validation Javascript
Hi I am creating validation for a form using javascript.
I am wanting to check the telephone number field using if statements to ensure it contains a 4 digit area code then a space followed by a 7 digit number.
Any help would be appreciated.
Thanks
So you need to validate something like 1234 1234567
function isValidTel(numberToTest){
var pattern =/^\d{4} \d{7}$/
return pattern.test(numberToTest);
}
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
A comprehensive regex for phone number validation
Whats the regex for
xxx-xxx-xxxx
or
(xxx)xxx-xxxx
I can create regex for the first one with
/^\d{3}-\d{3}-\d{4}$/
but how to add rule in this so it can also handle the second one?
You can use this: -
/^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/
I'm no guru but this should do the trick;
/^(\d{3}\-)?(\(\d{3}\))?\d{3}\-\d{4}$/
/^(\(\d{3}\))|(\d{3}-)\d{3}-\d{4}$/