Home >Backend Development >PHP Tutorial >javascript - next quotation mark problem after php regular match
<code>$html = <<<EOF <a href="a.php?u=ABjhpIVC;b=5" onmousedown="return rwt(AFQjCNH3RnE94GMEJkoxp0Iy1fSbpjbbwQ)">title</a> EOF; $isMatched = preg_match('/<a(.*?)href="(.*?)">(.*?)<\/a>/', $html, $matches);</code>
I used this code to finally match the content from to
">title
The final output result
a.php?u=ABjhpIVC;b=5" onmousedown="return rwt (AFQjCNH3RnE94GMEJkoxp0Iy1fSbpjbbwQ)
I want to get the content between the first double quotation mark and the second quotation mark, which is the content of the a tag href=
I don’t need to get the content from the first quotation mark to the last double quotation mark, please ask How can I modify this code to match it?
<code>$html = <<<EOF <a href="a.php?u=ABjhpIVC;b=5" onmousedown="return rwt(AFQjCNH3RnE94GMEJkoxp0Iy1fSbpjbbwQ)">title</a> EOF; $isMatched = preg_match('/<a(.*?)href="(.*?)">(.*?)<\/a>/', $html, $matches);</code>
I used this code to finally match the content from to
">title
The final output result
a.php?u=ABjhpIVC;b=5" onmousedown="return rwt (AFQjCNH3RnE94GMEJkoxp0Iy1fSbpjbbwQ)
I want to get the content between the first double quotation mark and the second quotation mark, which is the content of the a tag href=
I don’t need to get the content from the first quotation mark to the last double quotation mark, please ask How can I modify this code to match it?
Then you have to use greedy matching~/<a(.*?)href="(.*)">(.*?)</a>/
You use .*?
is followed by "
and he will stop as long as he matches the next character "
Using forbidden greedy matching U
Personal experience, when you write the regular expression, always add Uis
'/