So I tried this regex:
$email = '';
preg_match('<.*?>', 'sadfas<email@email.com>', $email);
echo $email[0];
The target result is so to extract ’email@email.com’ since it is between the < and > sign…but it did not work…
What did I do wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You forgot the regular expression delimiters (
/is a popular delimiter). You should also use a sub-pattern to match only the address and not the<>:Alternatively, you could do a look-ahead and look behind to avoid using the sub-pattern: