I've looked around for an answer, but I can't find anything that works for what I'm trying to achieve.
I have a page with URLs written in a pre tag, I am using the following to automatically replace any URL with the corresponding clickable link:
(function($) {
$(window).load(function() {
var tpage = $("pre");
tpage.html(tpage.html().replace(/box.php/ig, '<a target="_blank" href="/box.php">box.php</a>'));
tpage.html(tpage.html().replace(/sms.php/ig, '<a target="_blank" href="/sms.php">sms.php</a>'));
});
})(jQuery)
And this works perfectly fine. However, I have two pages that are cards.php and gcards.php. Using the code above for cards.php also matches the 'cards.php' in 'gcards.php', and thus, the gcards.php link is not made. If I put the gcards line before the cards one, it just messes up the gcards links.
I looked around and found this, but I can't seem to get the code to work at all.
Is there any way to make it so that the code only replaces 'cards.php' exactly, leaving 'gcards.php' alone for the other line of code?
Thank you.