Php regular expression matching problem $ t ='
Chrome
Test
';
$ Pre_reg = '/.*? Preg_match_all ($ pre_reg, $ t, $ matches );
Print_r ($ matches );
$ T I have omitted others and only left the main information, but even so, it still cannot be output. what is the problem?
(My intention is to matchChromeD8 % C1 % D0 % CB % B9 and chrome)
Reply to discussion (solution)
$ Pre_reg = '/.*?
$t='chrometest';$find='/href="\/f\?kw=([^"]*?)"\stitle="([^"]*?)"/s';preg_match_all($find,$t,$res);echo "";print_r($res);echo "
";/*Array( [0] => Array ( [0] => href="/f?kw=chrome" title="chrome" [1] => href="/f?kw=%CA%A5%B0%B2%B5%" title="test" ) [1] => Array ( [0] => chrome [1] => %CA%A5%B0%B2%B5% ) [2] => Array ( [0] => chrome [1] => test ))*/
$t='chrometest';$find='/href="\/f\?kw=([^"]*?)"\stitle="([^"]*?)"/s';preg_match_all($find,$t,$res);echo "";print_r($res);echo "
";/*Array( [0] => Array ( [0] => href="/f?kw=chrome" title="chrome" [1] => href="/f?kw=%CA%A5%B0%B2%B5%" title="test" ) [1] => Array ( [0] => chrome [1] => %CA%A5%B0%B2%B5% ) [2] => Array ( [0] => chrome [1] => test ))*/
It seems wrong. this is my original data:
Manage what I like _ Baidu Post Bar