Regular Expressions 101

Community Library Entry

0

Regular Expression
Golang

`
^(?P<local>[a-zA-Z0-9.!#$%&'*+/=?^_\x60{|}~-]+)@(?P<domain>[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$
`
gm

Description

A regexp to validate an email address according to https://html.spec.whatwg.org/#valid-e-mail-address . Note that the backslash in the name part of the regexp on that site is there to escape the forward slash, which is not needed in Go.

EDIT: This is newer than the version at https://regex101.com/library/RzBwPX, somehow a space snuck in there.

Submitted by markus@maragu.dk - 3 years ago