php - preg_match works in 'Hifi Reg Tester' but returns 'false' in code -


sorry ask simple question here problem. i'm modifying plancakeemailparser fit needs.

i made simple regex :

/([^:]+) (<+.*>)$/ 

that should match :

john doe <johndoe@fakemail.com> 

i tested in http://www.gethifi.com/tools/regex works perfectly

but in code returns false !

here 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 echo feedback :

value: john doe <johndoe@fakemail.com> preg_match: 0 

does of understand problem ?

thank !

edit

the problem made htmlentities on content, <> converted.

the solution rewrite regex :

/([^:]+) (<+.*>)$/ 

to this

/([^:]+) (&lt;+.*&gt;)$/ 

thank peter alfvin tryin :)

maybe someday

solved problem made htmlentities on content, <> converted. solution rewrite regex :

/([^:]+) (<+.*>)$/ /([^:]+) (&lt;+.*&gt;)$/ 

or remove htmlentities content , use when needed, did !

maybe someday...


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -