()[\]\\.,;:\ s@ \"]+)*)|(\".+\")) @((\[[0-9]{1,3}\.[...">

Can someone explain what this regular expression email means?

^(([^<>()[\]\\.,;:\ s@ \"]+(\.[^<>()[\]\\.,;:\ s@ \"]+)*)|(\".+\")) @((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.) +[a-zA-Z]{2,}))$ 

I could only understand the parts of the regular expression, but not the whole expression, for example

([^<>()[\]\\.,;:\ s@ \"]+(\.[^<>()[\]\\.,;:\ s@ \"]+)*)

matches one or more characters that are not characters

 <>()[\]\\.,;:\ s@ \" \\ Not sure what this [\]\\ and \ s@ \ means 

I could understand some other parts, but not as a single entity.

+4
source share
3 answers

Here you go:

 ^( ( [^<>()[\]\\.,;:\ s@ \"]+ // Disallow these characters any amount of times ( \. // Allow dots [^<>()[\]\\.,;:\ s@ \"]+ // Disallow these characters any amount of times )* // This group must occur once or more ) | // or (\".+\") // Anything surrounded by quotes (Is this even legal?) ) @ // At symbol is litterally that ( // IP address ( \[ // Allows square bracket [0-9]{1,3} // 1 to three digits (for an IP address \. // Allows dot [0-9]{1,3} // 1 to three digits (for an IP address \. // Allows dot [0-9]{1,3} // 1 to three digits (for an IP address \. // Allows dot [0-9]{1,3} // 1 to three digits (for an IP address \] // Square bracket ) | // OR a domain name ( ([a-zA-Z\-0-9]+\.) // Valid domain characters are a-zA-Z0-9 plus dashes + [a-zA-Z]{2,} // The top level (anything after the dot) must be at least 2 chars long and only a-zA-Z ) )$ 
+5
source

Here is a simple illustration from debuggex.com

First group

Second group

+5
source

"Not sure what this means [\]\\ and \ s@ \" "

\] is shielded ]
\\ is shielded \
\s - any empty space @ - @
\" is shielded "

"which means" + "

+ means "one or more" of what precedes +

+4
source

Source: https://habr.com/ru/post/1478851/


All Articles