Matching data from file with regex
问题 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+)$