I have this complex PHP I copied online:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
How do I run it in PHP? I try this:
$test = 'Joe Doe <doe@example.com>, postmaster@example.com, root, "Bob Smith" <bob@smith.com>';
$regex = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/';
print preg_match_all($regex, $test , $matches);
print_r($matches);
I try to escape it, but the complexity escapes me instead.
EDIT: Online Regex Tester show this regex is correct, I just don't know how to get it into PHP:
http://regexpal.com/?flags=g®ex=%5Ba-z0-9!%23%24%25%26%27*%2B%2F%3D%3F%5E_%60%7B%7C%7D~-%5D%2B(%3F%3A%5C.%5Ba-z0-9!%23%24%25%26%27*%2B%2F%3D%3F%5E_%60%7B%7C%7D~-%5D%2B)*%40(%3F%3A%5Ba-z0-9%5D(%3F%3A%5Ba-z0-9-%5D*%5Ba-z0-9%5D)%3F%5C.)%2B%5Ba-z0-9%5D(%3F%3A%5Ba-z0-9-%5D*%5Ba-z0-9%5D)%3F&input=Joe%20Doe%20%3Cdoe%40example.com%3E%2C%20postmaster%40example.com%2C%20root%2C%20%22Bob%20Smith%22%20%3Cbob%40smith.com%3E