javascript - Strip contact information from email -
i have users enter emails like:
john smith <john@example.org>
i have regex /(.+[ <>])/g
not correct this.
i have output like:
john@example.org
i want email component, , want ignore else user may give.
edit: people getting confused. want input turn out output. has nothing validation. have validation. has cleaning input before gets validation.
assuming e-mail input has "@" symbol, can select single token e-mail makes symbols you'd accept. example:
[a-za-z0-9.]*?@[a-za-z0-9.]*
test test test john smith@hotmail.com test
will result in
smith@hotmail.com
e-mails can contain dashes , underscores (john-smith@hotmail.com
), consider adding them [a-za-z0-9.]
character class, making [a-za-z0-9.\-_]
, or whatever characters feel appropriate.
Comments
Post a Comment