rupam_jaiswal Posted July 16, 2008 Share Posted July 16, 2008 Hi, I have to write a regular expression to fetch a email from the given type of string. Eg "Customer Service" <[email protected]> so I have to extract email I,e [email protected] But this can also be “<customer service>” <[email protected]. So I have to find string like search first ‘<’ after second double quote(” “ ) Thanks in advance Link to comment https://forums.phpfreaks.com/topic/115014-fetch-email/ Share on other sites More sharing options...
JasonLewis Posted July 19, 2008 Share Posted July 19, 2008 Here, try this: $str = '"Customer Service" <[email protected]>'; $str = preg_match("/[a-zA-Z_]+@[a-zA-Z]+\.[a-zA-Z]{2,4}/",$str,$matches); echo $matches[0]; Link to comment https://forums.phpfreaks.com/topic/115014-fetch-email/#findComment-593962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.