0% found this document useful (0 votes)
3 views

CSS RegularExpression

CSS regular expression

Uploaded by

Akash Khurd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CSS RegularExpression

CSS regular expression

Uploaded by

Akash Khurd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

 Checking for valid email address using regular expressions

"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$"

Where,

 ^ matches the starting of the sentence.


 [a-zA-Z0-9+_.-] matches one character from the English alphabet (both cases), digits, "+",
"_", "." and, "-" before the @ symbol.
 + indicates the repetition of the above-mentioned set of characters one or more times.
 @ matches itself.
 [a-zA-Z0-9.-] matches one character from the English alphabet (both cases), digits, "." and
"–" after the @ symbol.
 $ indicates the end of the sentence.

 validate phone number Javascript

/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/

What does it mean? Let’s break it down:

 /^\(?: The number may start with an open parenthesis.

 (\d{3}): Then three numeric digits must be entered for valid formats. If there is no

parenthesis, the number must start with these digits.

 \)?: It allows you to include a close parenthesis.

 [- ]?: The string may optionally contain a hyphen. It can be placed either after the

parenthesis or following the first three digits. For example, (123)- or 123-.

 (\d{3}): Then the number must contain another three digits. For example, it can look

like this: (123)-456, 123-456, or 123456.

 [- ]?: It allows you to include an optional hyphen in the end, like this: (123) -456-, -

123- or 123456-.

 (\d{4})$/: Finally, the sequence must end with four digits. For example, (123) -456-

7890, 123-456-7890, or 123456-7890.

You might also like