Heim > Artikel > Backend-Entwicklung > 正则表达式 - 如何用php匹配出这段代码?
有这样一段代码
<code><div> <div> <span><span>网盘链接: </span> </span> <span><a href="/ntcweb?id=d866a750-9cec-430a-9ea0-5cfbd6a2007a&level=2&pg=webz&uID=thJP9WeIiHG9tvFy&g_ut=2&key=jgf&url=http%3A%2F%2Fwww.%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97.com%2Fs%2F1qX18Rky">http://www.×××××××.com/s/1qX18Rky</a> </span> </div> <div></div> </div></code>
我想把a标签里的http://www.×××××××.com/s/1qX18Rky匹配出来?
请问正则怎么写?
麻烦不要把
有这样一段代码
<code><div> <div> <span><span>网盘链接: </span> </span> <span><a href="/ntcweb?id=d866a750-9cec-430a-9ea0-5cfbd6a2007a&level=2&pg=webz&uID=thJP9WeIiHG9tvFy&g_ut=2&key=jgf&url=http%3A%2F%2Fwww.%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97.com%2Fs%2F1qX18Rky">http://www.×××××××.com/s/1qX18Rky</a> </span> </div> <div></div> </div></code>
我想把a标签里的http://www.×××××××.com/s/1qX18Rky匹配出来?
请问正则怎么写?
麻烦不要把
<code class="php"><?php $text = <<<TEXT <div> <div> <span><span>网盘链接: </span> </span> <span><a href="/ntcweb?id=d866a750-9cec-430a-9ea0-5cfbd6a2007a&level=2&pg=webz&uID=thJP9WeIiHG9tvFy&g_ut=2&key=jgf&url=http%3A%2F%2Fwww.%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97%C3%97.com%2Fs%2F1qX18Rky">http://www.×××××××.com/s/1qX18Rky</a> </span> </div> <div></div> TEXT; preg_match('/<a>]+>([^/', $text, $matches); print_r($matches); ?></a></code>
<code>/(?]*>)[^)/</code>