Introductory paragraph (replace this with your text)
Matching an Email: /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
- Anchors
- Quantifiers
- Grouping Constructs
- Bracket Expressions
- Character Classes
- Character Escapes
- Explanation
^ Matches any string that start with characters placed after it.
^Hello Matches a string that starts with Hello.
$ Matches any string that ends with characters placed before it.
World$ Matches a string that ends with World.
+ Matches a string that has one or more of the group before it.
a+ String has one or more a in a row.
{2,6} Matches a string followed by 2 up to 6 of the group before it.
a{2,6} String has 2 up to 6 a characters in a row.
a(bc) Creates a group of the characters bc
Allows you to group bracket expressions, character classes, quantifiers, and other regex components together.
[abc] Matches a string with either a, b, or c. Same as [a-c]
[a-z0-9] String has a single character that is a through z or 0 through 9.
\d Matches a character that is also a digit.
\? In order to search the following character they must be preceded by a backslash ^.[$()|*+?
\\. Matches a string that contains a period.
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
-There are three major sections
- /^([a-z0-9_\.-]+)
- ^() means the string starts with the group in the parenthesis.
- ([a-z0-9_\.-]+) => []+ the string contains any number of the characters in the bracket expression.
- a-z0-9_\.- contains characters a through z, 0 through 9, underscore, period, or a dash.
- The string begings with any number of characters a through z, 0 through 9, underscore, period, or a dash.
- @([\da-z\.-]+)
- The first section is followed by an @ character followed by the next group ([\da-z\.-]+)
- [\da-z\.-]+ => the string contains any number of the characters in the bracket expression.
- \da-z\.- Contains a character that is a digit (\\d), a through z, period, or a dash.
- The string contains an @ sign followed by any number of digits, a through z, period, or dash.
- \.([a-z\.]{2,6})$/`
- The second section is follow by a period and a string ending with the final group ()$
- ([a-z\.]{2,6}) Contains 2 up to 6 character of the preceding bracket expression.
- [a-z\.] Contains a through z, or period.
- The string contains a period followed by a string ending with more than 2 and up to 6, a through z or periods.
- Final
- The string begings with any number of characters a through z, 0 through 9, underscore, period, or a dash
- followed by an @ sign followed by any number of digits, a through z, period, or dash followed by a period
- then ending with more than 2 and up to 6, a through z or periods.