[英]Replace all HTML tags except for <strong>, </strong>, <b> and </b>
[英]Wrapp link in strong with replace()
我想在div中圍繞我的鏈接制作一個強大的標簽。 這些鏈接動態顯示。
我試着這樣做:
$('#alertWrapp').each(function() {
$(this).html($(this).text()
.replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
.replace('http://', '<strong>$&</strong>')
);
});
但我不能繼續正則表達式,它太復雜了......所以有可能建立一個正在尋找http:// protocole到空間的正則表達式? 因為這是一個設置鏈接結束的空間......
謝謝
要替換http:// [任何直到空格]或https:// [任何]嘗試此操作
$('#alertWrapp').each(function() {
$(this).html(
$(this).text()
.replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
.replace(/https?:\/\/[^ ]+/g, '<strong>$&</strong>')
);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.