smerny Posted February 23, 2012 Share Posted February 23, 2012 I have a string that can be "Billy Bob <[email protected]>" or "[email protected]" how can I make it so that if it is like the first example, it will just pull the email address? Link to comment https://forums.phpfreaks.com/topic/257587-js-regex-to-pull-an-email-address/ Share on other sites More sharing options...
requinix Posted February 23, 2012 Share Posted February 23, 2012 If those are the only two possibilities, // will grab the email. If it fails then the whole string is the email. Link to comment https://forums.phpfreaks.com/topic/257587-js-regex-to-pull-an-email-address/#findComment-1320292 Share on other sites More sharing options...
AyKay47 Posted February 23, 2012 Share Posted February 23, 2012 I have a string that can be "Billy Bob <[email protected]>" or "[email protected]" how can I make it so that if it is like the first example, it will just pull the email address? Does any sanitation need to be done to the string? Will the string always contain a valid email address or is this unreliable data that needs to be checked for a valid email address as well? Link to comment https://forums.phpfreaks.com/topic/257587-js-regex-to-pull-an-email-address/#findComment-1320293 Share on other sites More sharing options...
smerny Posted February 23, 2012 Author Share Posted February 23, 2012 sanitation not necessary in this case, req's solution will work thanks Link to comment https://forums.phpfreaks.com/topic/257587-js-regex-to-pull-an-email-address/#findComment-1320294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.