preg_match works in 'Hifi Reg Tester' but returns 'false' in code
Sorry to ask a so simple question but here is my problem. I'm actually
modifying the PlancakeEmailParser to fit my needs.
I made a simple regex :
/([^:]+) (<+.*>)$/
that should match with :
John DOE <johndoe@fakemail.com>
I tested it in http://www.gethifi.com/tools/regex it works perfectly
But in my code it returns false !
Here is the offending code :
preg_match('/([^:]+): ?(.*)$/', $line, $matches);
$newHeader = strtolower($matches[1]);
$string = $matches[2];
$reg = "/([^:]+) (<+.*>)$/";
echo 'VALUE: '.$string."\n";
echo 'PREG_MATCH: '.preg_match($reg, $string)."\n\n";
if (preg_match('/([^:]+) (<+.*>)$/', $matches[2])) {
echo('match'."\n\n\n\n");
} else {
$value = $matches[2];
}
Here is the echo feedback :
VALUE: John DOE <johndoe@fakemail.com>
PREG_MATCH: 0
Does anyone of you understand what is the problem ?
Thank you very much !
No comments:
Post a Comment