开发者

fixing a regex pattern to be more precise

开发者 https://www.devze.com 2023-03-05 09:47 出处:网络
alertsystem.notification = {\"msgId\":\"1\",\"msgTitle\":\"Message\",\"msgBody\":\"No new message.\",\"msgLink\":\"\",\"msgImage\":\"\"};
alertsystem.notification = {"msgId":"1","msgTitle":"Message","msgBody":"No new message.","msgLink":"","msgImage":""};

I am trying to match the values for of the follow variables in the code above. I have been using this pattern preg_match('#(\[\{.*?\}\])#s', $html, $match); up until last week then it stopp开发者_JAVA百科ed working.

Is there a way to include alertsystem.go = in the pattern so that I am sure to get a match?


You want preg_match_all and then take a look at $matches[0]. Your regex could also be: #alertsystem\.notification\s*\=\s*\{.*?\}#is

Add parenthesis where appropriate to capture specific sections.

0

精彩评论

暂无评论...
验证码 换一张
取 消