问题
The file I am pulling the data from consists of the following information
<"DATA" 10.21
^"DATA" 81.39
_"DATA" 38.71
"DATA" 84.19
Using preg_match, how can I pull the values from each?
I tried $r = '/<"DATA" (.+?)/';
but it didn't give me the numbers.
Anyone know the correct regex to pull these numbers?
Thanks in advance!
回答1:
preg_match_all('/^\s*.?"DATA" (\d+)\.(\d+)\s*$/m', $str, $matches);
CodePad.
回答2:
You have to use the preg_match_all function:
preg_match_all('/^[<^_ ]"DATA" (\d+\.\d+)$/m', $string, $matches);
// look in $matches
来源:https://stackoverflow.com/questions/7076684/matching-data-from-file-with-regex