How to implement the regular expression of verifying email address and the corresponding version of various languages
The purpose of this article is to share with you how to implement regular expressions for verifying email addresses and corresponding versions in various languages. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Universal
The code is as follows:
(?): [a-z0-9 license registration% license registration scale? ^ _ `{|} ~ -] + (?:\. [a-z0-9 license license% license license registration balance? ^ _` {|} ~ -] +) * | (: [\ x01 -\ x08\ x0b\ x0c\ X0e -\ X1f\ x21\ x23 -\ x5d -\ x7f] |\ [\ x01f -\ x09\ x0b\ x0c\ X0e-\ X7f]) @ (?: [a-z0-9] (?: [a-z0-9 -] * [a-z0-9])?\.) + [a-z0-9] (?: [a-z0-9 -] * [a-z0-9])? |\ [(?: (?) 25 [0-5] | 2 [0-4] [0-9] | [01]? [0-9] [0-9]?) {3} (?) [0-5] | 2 [0-4] [0-9] | [01]? [0-9] [0-9]? | [a-z0-9 -] * [a-z0-9]: (?: [\ x01 -\ x08\ x0b\ x0c\ X0e -\ x21 -\ x5a\ x53 -\ x7f] |\ [\ x01 -\ x09\ x0b\ X0c\ x0e\ x7f]) +)\])
Python
R "(^ [a-zA-Z0-9 colors -] + @ [a-zA-Z0-9 -] +\. [a-zA-Z0-9 color.] + $)"
Javascript
The code is as follows:
/ ^ [- a-z0-9 benchmark% ^ & * _ = +} {\'?] + (\. [- a-z0-9 resume% ^ & * _ = +} {\\'?] +) * @ ([a-z0-9 _] [- a-z0-9 _] * (\. [- a-z0-9 _] +) *\. (aero | arpa | biz | com | coop | gov | info | int | mil | name | net | org | pro | travel | mobi | [ACPZ] [aanthz]) | ([0-9] {1je3}\. [0-9] {1cane3}. }\. [0-9] {1Magne3}\. [0-9] {1pr 3})) (: [0-9] {1Jet 5})? $/ I
PHP
The code is as follows:
/ ^ (?) (: (?:\ x22?\ x5C [\ x00 -\ x7e]\ x22?) | (?:\ x22? [^\ x5C\ x22]\ x22?) {255,}) (?) (: (:\ x22?\ x5C [\ x00 -\ x7E]\ x22?) | (?:\ x22? [^\ x5C\ x22]\ x22?) {65 } @) (?: (?: [\ x21\ x23 -\ x27\ x2A\ x2B\ x2D\ x2F -\ x39\ x3D\ x3F\ x5e -\ x7e] +) | (?: [\ x01 -\ x08\ x0B\ x0C\ x0E -\ x1F\ x21\ x23 -\ x5D -\ x7F]) (?:\ x5C [\ x00 -\ x7F]) *\ x22)) (?:\. (?): [\ x21\ x23 -\ x2A\ x2B \ x2D\ x2F -\ x39\ x3D\ x3F\ x5e -\ x7e] +) | (?:\ x22 (?: [\ x01 -\ x08\ x0B\ x0C\ x0E -\ x1F\ x21\ x23 -\ x5B\ x5D -\ x7F]) * @ (: (?: (?) }) (?: xn--)? [a-z0-9] + (?:-[a-z0-9] +) *\.) {1126}) {1 } (?: (: [a-z0-9] *) | (?: (: xn--) [a-z0-9] +)) (?:-[a-z0-9] +) *) | (?:\ [: IPv6: (?: [a-f0-9] {1Currentin 4} (:: [a-f0-9] {1pm 4}) {7}) | -f0-9] [:\]]) {7 }) (?: [a-f0-9] {1Magne 4} (?:: [a-f0-9] {1pr 4}) {0Magne 5}): (: [a-f0-9] {1pr 4} (?:: [a-f0-9] {1pr 4}) {0pr 5}) | (: (: IPv6: (?): [a-f0-9] {1jue 4} (?:: [a-f0-9] {1pm 4}) {5}:) ?: (?! (?:. * [a-f0-9]:) {5 }) (?: [a-f0-9] {1Mague 4} (?:: [a-f0-9] {1Mague 4})): (: [a-f0-9] {1Power4} (?:: [a-f0-9] {1pr 4}) {0jue 3}:)? (: (?): 25 [0-5]) | (?: 2 [0-4] [0-9]) | (?: 1 [0-9] {2}) | ?: [1-9]? [0-9]) (?:\. (: 25 [0-5]) | (?: 2 [0-4] [0-9]) | (: 1 [0-9] {2}) | (: [1-9]? [0-9])) {3}) $/ iD
Perl / Ruby
(?: (?:\ r\ n)? [\ t]) * (: [^ () @,;:\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [])) |" (?: [^\ "\ r\\] |\\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) * (?:\. (: (?:\ r\ n)? [\ t]) * (: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?: (: (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t])) * @ (?: (?:\ r\ n)? [\ t]) * (?: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ []) |\ [([^\ [\]\ r\] |\\.) *\] (?: (?:\ r\ n)? [\ t]) (?:\. (: (?:\ r\ n)? [\ t]) * (?: [^ () @ :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @,;:\ ". [])) |\ [([^ [\]\ r\] |\\.) *] (?: (?:\ r\ n)? [[\ t]) * | (?: [^ () @ @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) *) * (?: (?:\ r\ n)? [\ t]) *) | (?: [^ () @ @) :\\ ".\ [\]\ 000 -\ 031] + (?: (: (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) *: (?: (?:\ r\ n)? [\ t]) * (?: [^ () @ @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [])) |" (?: [^\ "\ r\\] |\\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) * (?:\. (: (?:\ r\ n)? [\ t]) * (: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t])) * @ (?: (?:\ r\ n)? [\ t]) * (?: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ []) |\ [([^\ [\]\ r\] |\\.) *\] (?: (?:\ r\ n)? [\ t]) (?:\. (: (?:\ r\ n)? [\ t]) * (?: [^ () @ :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @,;:\ ". [])) |\ [([^ [\]\ r\] |\\.) *] (?: (?:\ r\ n)? [[\ t]) * | (?: [^ () @ @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) *) * (?: (?:\ r\ n)? [\ t]) *) (?:,\ s* (?: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [])) |" (?: [^\ "\ r\\] |\\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) * (?:\. (: (?:\ r\ n)? [\ t]) * (: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t])) * @ (?: (?:\ r\ n)? [\ t]) * (?: [^ () @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ []) |\ [([^\ [\]\ r\] |\\.) *\] (?: (?:\ r\ n)? [\ t]) (?:\. (: (?:\ r\ n)? [\ t]) * (?: [^ () @ :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @,;:\ ". [])) |\ [([^ [\]\ r\] |\\.) *] (?: (?:\ r\ n)? [[\ t]) * | (?: [^ () @ @) :\\ ".\ [\]\ 000 -\ 031] + (?:\ r\ n)? [\ t]) + |\ Z | (? = [\ [" () @ :\\ ".\ [[]])) |" (?: [^\ "\ r\] |\. | (?: (?:\ r\ n)? [\ t])) *" (?: (?:\ r\ n)? [\ t]) *) * (: (?:\ r\ n)? [\ t]) *);\ s*)
Perl 5.10 or newer
/ (? (DEFINE) (? (? & mailbox) | (? & group)) (? (& name_addr) | (? & addr_spec)) (? (? & display_name)? (? & angle_addr)) (? (? & CFWS)?
< (?&addr_spec) >(? & CFWS)) (? (& display_name): (?: (& mailbox_list) | (? & CFWS))? (CFWS)) (? (phrase)) (? (? & mailbox) (?) (? & mailbox)) *) (? (? & local_part)\ @ (? & domain)) (? (? & dot_atom) | (? & quoted_string)) (? (& dot_atom) | (? & domain_literal)) (? (? & CFWS)?\ [(?: (? & FWS)? (? & dcontent)) * (? & FWS)?\] (? & CFWS)?) & dtext) | (? & quoted_pair)) (? (? & NO_WS_CTL) | [\ x21 -\ x5a\ x5e -\ x7e]) (? (? & ALPHA) | (? & DIGIT) | [! #\ $% &'* +-/ = ^ ^ `{|} ~]) (? (? & CFWS)? (? & atext) + (? & CFWS)?) (? (? & CFWS)? (? & dot_atom_text) ? & CFWS)) (? (? & atext) + (?:\. (? & atext) +) *) (? [\ x01 -\ x09\ x0b\ x0c\ x0e -\ x7f]) (?\ (? & text) (? (? & NO_WS_CTL) | [\ x21\ x23 -\ x5b\ x5d -\ x7e]) (? (? & qtext) | (? & quoted_pair)) (? (? & CFWS)? (? & DQUOTE) (?: (? & FWS)? (? & qcontent)) * ? & FWS)? (? & DQUOTE) (? & CFWS)) (? (? & atom) | (? & quoted_string)) (? (? & word) +) # Folding white space (? (?: (? & WSP) * (? & CRLF))? (? & WSP) +) (? (? & NO_WS_CTL) | [\ x21 -\ x27\ x2a -\ x5b\ x5d -\ x7e]) (? (& ctext) | ? & comment) (?\ (: (? & FWS)? (? & ccontent)) * (? & FWS)?\)) (? (: (? & FWS)? (? & comment) * (?: (: (? & FWS)? (? & comment)) | (? & FWS) # No whitespace control (? [?\ x01 -\ X08\ x0b\ X0c\ X0e-\ X1f\ x7f]) [A-Za-z]) (? [0-9]) (?\ x0d\ x0a) (? ") (? [\ x20\ x09])) (? & address) / x
Ruby (simpler version)
/\ A ([\ w+\ -].) + @ [amurz\ d\ -] + (\ .[ a-z] +) *. [amerz] +\ zgami
.NET
^\ w+ ([- +.']\ w+) * @\ w+ ([-.]\ w+) *. Thank you for reading! This is the end of the article on "how to verify the regular expressions of email addresses and the corresponding versions of various languages". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!