9
回答
有关正则表达式问题,请高手解答
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

以下为一段文本:

<p>All the slots game in slotsmamma.com are free and just play for fun. We work on these slot machines as a labor of love, with the hopes that people will find it useful, and in turn share it with their own friends and family. We welcome you to join us to test the new online slots, <a href="/dinosaur/">Jurassic Park</a>, <a href="/penny-slots/">Penny Slots</a>, <a href="/loose-slots/">Loose Slots</a>, <a href="/super-slots/">Super Slot o bot</a>, <a href="/cash-cruiser/">Cash Cruiser</a>, <a href="/million-dollar-rally/">Million Dollar Rally</a>, <a href="/jungle-adventures/">Jungle Adventures Slots</a>, <a href="/snow-mountain/">Snow Mountain Slot</a>,  or ourfirst <a href="/bonus/">Bonus Slots</a>.dfdf</p>

要求是取出a标签并左右两边的字符,例:

左边文本<a href="aaa">dfdfdf</a>右边文本

以下是我提出的内容,有一段不对,不知怎整。

All the slots game in slotsmamma.com are free and just play for fun. We work on these slot machines as a labor of love, with the hopes that people will find it useful, and in turn share it with their own friends and family. We welcome you to join us to test the new online slots, <a href="/dinosaur/">Jurassic Park</a>,
<a href="/penny-slots/">Penny Slots</a>,
<a href="/loose-slots/">Loose Slots</a>,
<a href="/super-slots/">Super Slot o bot</a>,
<a href="/cash-cruiser/">Cash Cruiser</a>,
<a href="/million-dollar-rally/">Million Dollar Rally</a>,
<a href="/jungle-adventures/">Jungle Adventures Slots</a>,
<a href="/snow-mountain/">Snow Mountain Slot</a>,  or ourfirst
<a href="/bonus/">Bonus Slots</a>.dfdf


问题是:<a href="/bonus/">Bonus Slots</a>.dfdf 这段的左边没有字符串

正确应该是:,  or ourfirst<a href="/bonus/">Bonus Slots</a>.dfdf

以下是我的正则:

([^>]*)<a\s([^>\n\s]*)href=(\"|\'|[^\s])?((https|http|\/|\./|\w|\d|_|)(.*?))[\"|\'|^\s][^>]*>(.*?)</a>(([^<])*)


举报
丰圣谋
发帖于4年前 9回/401阅
顶部