Your pattern contains a lookbehind and Safari does not support lookbehinds yet. Actually, the (?!-)[a-zA-Z0-9-]+(?<!-)
pattern means to match one or more alphanumeric or hyphen chars while forbidding -
to appear at the start and end of this sequence. It is simple to refactor this pattern part to [a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*
.
So, the regex will look like
/^[a-zA-Z0-9.!#$%&'*+-/=?^_{|}~]+@[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*.[a-zA-Z]{2,}$/
[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*
matches one or more alphanumeric chars and then any zero or more sequences of a hyphen followed with one or more alphanumeric chars.
Note you may simply use @
instead of [@]
as @
is never special in any regex, and [.]
can be written as .
, which means a literal dot.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…