I would like make a strong tag around my links in a div. These links appear dynamically.
I tried to do this :
$('#alertWrapp').each(function() {
$(this).html($(this).text()
.replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
.replace('http://', '<strong>$&</strong>')
);
});
But I can't continue the regex, it's too much complex... So it can be possible to build a regex who find the http:// protocole to space ? because it's a space who set the end of my links...
Thanks you
To replace http://[anything-until-space] or https://[anything] try this
$('#alertWrapp').each(function() {
$(this).html(
$(this).text()
.replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
.replace(/https?:\/\/[^ ]+/g, '<strong>$&</strong>')
);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.