用于从<a>超链接
Regex for removing jQuery attribute from <a> hyperlinks
我想从字符串中删除jQuery属性。请建议正则表达式。
<A href="http://www.yahoo.com" jQuery1327469683587="77" jQuery1327470207412="14">yahoo</A><BR>
var str = '<A href="http://www.yahoo.com" jQuery1327469683587="77" jQuery1327470207412="14">yahoo</A><BR>'
str = str.replace(/'sjQuery'd+="[^"]*"/g, "")
或者,如果"jQuery"后面的字符不是全部数字:
str = str.replace(/'sjQuery[^=]+="[^"]*"/g, "")
我喜欢以下实现方式:
var inputText = "<A jQuery1327469683587='"77'" href='"http://www.yahoo.com'" jQuery1327470207412='"14>'">yahoo</A><BR><A jQuery1327469683587='"77'" href='"http://www.yahoo.com'" jQuery1327470207412='"14>'">yahoo</A><A jQuery1327469683587='"77'" href='"http://www.yahoo.com'" jQuery1327470207412='"14>'">yahoo</A><A jQuery1327469683587='"77'" href='"http://www.yahoo.com'" jQuery1327470207412='"14>'">yahoo</A>";
var matchedTags = inputText.match(/<a[^<>]+[^=]">/gi); //Match all link tags
alert(matchedTags);
for(i = 0; i < matchedTags.length; i++) {
var stringBeforeReplace = matchedTags[i];
matchedTags[i] = matchedTags[i].replace(/'s+jQuery'w+="[^"]*"/g,"");
inputText = inputText.replace(stringBeforeReplace, matchedTags[i]);
}
alert(inputText);
相关文章:
- 制作一个不带HTML a标记但在动画播放完毕后指向其他页面的超链接
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 用超链接替换URLS
- 使用JavaScript从超链接加载时的默认下拉值
- Hammer.js阻止在Android Webview中点击超链接
- 将超链接添加到“;标题“;标记文本
- 文本建议的超链接
- 用Javascript按钮替换Javascript超链接
- 删除默认的ui超链接行为
- 谷歌将广告超链接映射到国家标记
- 如何在点击超链接时调用fullcalendar回调
- 单击“禁用其他超链接”
- 为Angularjs制作超链接
- 指向的超链接刚刚赢得'不起作用
- 如何将超链接添加到通过传单创建的传单多段线.Draw
- 如何禁用鼠标中键单击超链接以在新选项卡或新窗口中打开
- 如何在每个动态创建的ImageButton周围包装超链接?Visual Studio
- 将数据库中的超链接添加到查询结果
- 用于从<a>超链接
- 超链接标记“<a>"无法在html页面中工作