Email regex with min length and not max length [duplicate] - javascript

This question already has answers here:
How can I validate an email address in JavaScript?
(79 answers)
Closed 8 years ago.
I have this regex in JavaScript:
new RegExp('^[0-9a-z._-]+#{1}[0-9a-z.-]{2,}[.]{1}[a-z]{2,}$','i');
and I want to modify it.
The last part of the mail must have a minimum value: 2 chars and no maximum length so I can put mails such as .localhost .paris .thisismyexample ...
How may I do that?

new RegExp('\b[A-Z0-9._%+-]+#(?:[A-Z0-9-]+\.)+[A-Z]{2,}\b','i');

Related

How can I extract number from text with regular expression [duplicate]

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+(.)(?=€)

What to add to a regex IPv4 Validation to also validate CIDR IPv4? [duplicate]

This question already has answers here:
JS Validation IP:Port
(5 answers)
How can I make part of regex optional?
(2 answers)
Closed 3 years ago.
I have two function in JS that check if a typed input is a valid IPv4.
This is the regex that I got from #Abana Clara from this question: How to validate IP Address on multiple inputs?
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
I would like to add to this regex the possibility to also validate CIDR IPv4 addresses.
Please note that both of the following addresses should be valid:
192.168.1.20
192.168.1.20/24

How do I get the last character with jquery [duplicate]

This question already has answers here:
How to get the last character of a string?
(15 answers)
Closed 8 years ago.
I have a string I am trying to get the last character with jquery. How would I do that?
var stringTemp = "fieldNameWithIndex_1";
stringTemp.charAt(stringTemp.length-1);
or
stringTemp.slice(-1);
Use .split():
stringTemp.split('_')[1]

regex for phone number format (with dot) [duplicate]

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

Javascript telephone number validation [duplicate]

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);
}

Categories

Resources