Home >Backend Development >PHP Tutorial >正则表达式求解

正则表达式求解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:35:421287browse

请问想匹配下面字符串的正则表达式该怎么写:
每个需要匹配的项目都是以空格结尾的

server_model=ProLiant DL360 G5;;  server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz;;  cpu=21mhz;1;3;5;8 



回复讨论(解决方案)

问题没说清楚  

$s = "server_model=ProLiant DL360 G5;; server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz;; cpu=21mhz;1;3;5;8";preg_match_all('/\s*(\S.+)(?:;;|$)/U', $s, $m);print_r($m[1]);
Array(    [0] => server_model=ProLiant DL360 G5    [1] => server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz    [2] => cpu=21mhz;1;3;5;8)

感谢回复,已经很接近了,但我加了2个数据测试,发现了点小问题,烦请帮忙。谢谢!

server_model=ProLiant DL360 G5;; server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz;; swap=3989MB;0;0;0;3999 memory=158MB;;;;1869 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn