I am looking for a correct way to test a JavaScript regular expression for phone number and email address. This includes the RegExp string and the syntax.
First the syntax: I am confused about using the quote mark (“) in defing the RegExp.
Is it
var email_test = new RegExp(/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/);
or
var email_test = new RegExp(“/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/”);
Secondly, what RegExp have you used that works well for phone and email. These are the ones I found for phone and email
var email_test = new RegExp(/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/);
var phone_test = new RegExp(^([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}$);
Thanks!