I'm trying to get emails out of a string:
$string = "bla bla [email protected] MIME-Version: [email protected] bla bla bla";
$matches = array();
$pattern = '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b';
preg_match_all($pattern,$string,$matches);
print_r($matches);
The error I'm getting is :
Delimiter must not be alphanumeric or backslash
I got the regex syntax from here http://www.regular-expressions.info/email.html
Like this
$pattern = '/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i';
Or smaller version :)
$pattern = '/[a-z\d._%+-]+@[a-z\d.-]+\.[a-z]{2,4}\b/i';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With