I am trying to create a JavaScript program to replace certain patterns of text with links. However due to some of the patterns existing within a URL on the page it blocks the URL links.
I am specifically looking to exclude the pattern if it is contained within a URL so for example here is my current Regex code.
$els.replaceText(/(\bX00[A-Z0-9]{7}\b)/gi, '<span class="context context_ident">$1<\/span>');
Some Example Text:
item :X00132BhJk
www.domain.com/X00132BhJk
www.domainsearch.com/search?ident=X00132BhJk
X00132BhJk
X00132BhJk
The Italic References should be selected and replaced however the references contained within the domain should not. The issue I have been having is when the reference.
Initially I tried \sX00[A-Z0-9]{7}\s
but when the reference appears on the far left of the page (First word in the sentence) it doesn't get selected. Equally so it does not select if a full stop follows or a colon precedes.
Is there a way to specifically exclude URL's by excluding / ? and = from being the immediate preceding character but select in all other cases?