I have an input field that currently has this regex code:
[a-zA-Z0-9._] @[a-zA-Z0-9] .[a-zA-Z]{2,5}
I want to make it so it is able to verify email query URLs, like this:
[email protected]?subject=test%via web.co
Can anyone show me how to go about this?
CodePudding user response:
you can use the regex you have like this:
/[a-zA-Z0-9._] @[a-zA-Z0-9] .[a-zA-Z]{2,5}/.test(<the value of the input field>)
CodePudding user response:
This regex pattern will capture the 2 parts in 2 groups
^([^\s@?%] ?@[^\s@?%] ?\.[A-Za-z]{2,9})(\?[^\s]*)?$
^
: start of the line or string
([^\s@?%] ?@[^\s@?%] ?\.[A-Za-z]{2,9})
: Group 1: the e-mail
(\?[^\s]*)?
: optional Group 2: literal question mark and non-whitespace characters after it.
$
: end of the line or string