我想我几乎可以使用正则表达式,例如我有以下内容:
<li id="ctl00_dashboard1_liReports" class="fade_hover tooltip" title="Reports">
<a id="ctl00_dashboard1_HyperLink1" href="reportlist.aspx"><img id="ctl00_dashboard1_imgCheck3" src="assets/icons/dashboard/81.png" alt="Reports" style="border-width:0px;" />
<span>Reports</span></a></li>
<li id="ctl00_dashboard1_messagetitle" class="fade_hover tooltip" title="8 new alerts">
<a id="ctl00_dashboard1_messagelink" href="reportlist.aspx?sectionname=My+Tasks"><img id="ctl00_dashboard1_imgCheck4" src="assets/icons/dashboard/75.png" alt="My Tasks" style="border-width:0px;" />
<span>My Tasks</span></a><span class="bubble">8</span></li>
<li id="ctl00_dashboard1_adminli" class="fade_hover tooltip" title="Admin">
<a id="ctl00_dashboard1_lnkUser" href="/admin/useradmin.aspx"><img id="ctl00_dashboard1_imgCheck2" src="assets/icons/dashboard/54.png" alt="Admin" style="border-width:0px;" /><span id="ctl00_dashboard1_lbladmin">Admin</span></a></li>
<li id="ctl00_dashboard1_lilogout" class="fade_hover tooltip " title="End current session">
<a id="ctl00_dashboard1_lnkLogout" href="/default.aspx"><img src="assets/icons/dashboard/118.png" id="ctl00_dashboard1_imgCheck5" alt="Logout" />
<span>Logout</span></a></li>
我想用不同的字符串替换 href 之后的所有 .aspx 链接。我的正则表达式几乎就在那里,但是当查询字符串被击中时它会崩溃:
(("|')[a-z0-9\/\.\?\=\&]*(\.aspx|\.php|\.jsp)[a-z0-9\/\.\?\=\&]*("|"))|(href=*?[a-z0-9\/\.\?\=\&""]*)
它与以下内容匹配,但您可以在查询字符串的 = 处看到停靠点。任何帮助将不胜感激。