php - Couldn't get desired results via preg_match_all -


i trying program email piping php script take incoming traffic update report via email, , extract relevant information within store database.

the email starts introduction, important information displayed in following format.

highway : highway  time : 08-oct-2010 08:10  condition : smooth (or slow moving etc) 

i tried code

preg_match_all('/(?p<\name>\w+) : (?p<\data>\w+)/i', $subject, $result);

note < / < somehow not being displayed here.

and matches only:

highway : datetime : 08 condition : smooth 

can tell me what's missing in second regex expression? why doesn't include entire string of words after ":"?

you capturing \w+. matches word characters, not include spaces or parenthesis.

try

preg_match_all('/(?p<name>\w+)\s*:\s*(?p<data>.*)/i', $subject, $result); 

try using .*? match new line character


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -