In this way, how do I write the regular expression values in single and double symbols? This post was last edited by u013670343 at 21:44:46
ProId: '20140901 ',
'Proid': '123 ',
First question: how do I write a regular expression that is 123456789 compatible with the above two lines of code?
That is, whether it is using proId: '123', the value in it,
Or take the value in 'proid': '123,
If you write only one regular expression, you can get the value!
'Newsid': '123 ',
NewsId: "987654321 ",
The second question: how do I write a regular expression that is 987654321 compatible with the above two lines of code?
Whether it is 'newsid': '123', the value in it,
Or take the value in newsId: "987654321,
If you write only one regular expression, you can get the value!
Reply to discussion (solution)
['] * (? : ProId | newsId) ['] *: \ s * ['] * (\ d +) ['] *
['] * (? : ProId | newsId) ['] *: \ s * [\' \ "] * (\ d +) [\ '\"] *
First question
$ S = <
Second question
$ S = <
First:
/(\ ') {0, 1} newsId (\') {0, 1} :( \ '| \ ") (\ d +) (\' | \"),/
Second
/(\ ') {0, 1} userId (\') {0, 1} :( \ s *?) {0, 1} \ '(\ d + )\',/
$s =<<< TXTproId: '123456789','proId':'123456789','newsId':'987654321',newsId:"987654321",TXT;preg_match_all('/:\s*([\'"])(.+)\1/', $s, $r);print_r($r[2]);
Array
(
[0] = & gt; 123456789
[1] => 123456789.
[2] => 987654321.
[3] = & gt; 987654321
)