-5

PHP字符串与正则表达式爆炸示例数据:

"A" 100000  "M" "C" "J"         "JOHNSON TRENCHING" 238910

预期结果:

array (
  0 => 'A',
  1 => '100000',
  2 => 'M',
  3 => 'C',
  4 => '',
  5 => '',
  6 => 'JOHNSON TRENCHING',
  7 => '238910'
);
4

1 回答 1

1

尝试这个

$string = '"A" 100000 "M" "C" "J" "JOHNSON TRENCHING" 238910';
$string = preg_match_all('/(\"[a-zA-Z0-9\s]+\")|[0-9]+/', $string, $matches);

print_r($matches);
于 2013-05-17T13:18:54.167 回答