【发布时间】:2017-03-05 14:19:05
【问题描述】:
我在尝试从字符串中提取特定值但没有得到正确输出时遇到问题。
$string = com.xyz.ghop.service.sprint.Sprint@1b0258c[id=257,rapidViewId=94,state=CLOSED,name=Alert Success 5,goal=,startDate=2016-08-16T20:20:46.730+05:30,endDate=2016-08-26T20:20:00.000+05:30,completeDate=2016-08-26T21:18:53.928+05:30,sequence=257]
我想要 name= 中的值直到逗号,我尝试使用 preg_match_all 但它只给出第一个单词。
这是我尝试过的:
preg_match_all("/(?=name\=([^\W]+))/", $string, $matches);
$resulte = implode(",", $matches[1]);
请帮忙
谢谢
【问题讨论】:
-
你能展示一下你对
preg_match的尝试吗? -
preg_match_all("/(?=name\=([^\W]+))/", $string, $matches); $resulte = implode(",", $matches[1]);
标签: php string preg-match-all