smerny Posted February 23, 2012 Share Posted February 23, 2012 I have a string that can be "Billy Bob <Billy.Bob@gmail.com>" or "Billy.Bob@gmail.com" how can I make it so that if it is like the first example, it will just pull the email address? Quote 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. Quote 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 <Billy.Bob@gmail.com>" or "Billy.Bob@gmail.com" 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.