I've looked through numerous other questions up here surrounding a negative lookbehind for JavaScript but I can't seem to mimic them. I have the following Regex:
\b((?:http[s])?\S+\.\S+\.(?:\S+\.?){1,4})(?<!@)\b`
and the basis of this Regex is it matches web addresses like:
www.msn.com
- or
http://www.msn.com
- or
https://www.google.com
- or
http://msdn.microsoft.com
.
However, it also matches name@d1.d2.d3.d4
because of the numerous domain names following the @
sign. I need to perform a negative lookbehind for that @
sign.
Hopefully somebody can give me a hand!
UPDATE
Updating to include the replacement string that I'm using to create the hyperlink out of the matched text.
replace(webLinkPattern, "<a href=\"http://$2\" target=\"_blank\" onclick=\"preventDualEditing(event)\">$2</a>");
UPDATE 2 - ANSWER
ts = ts.replace(webLinkPattern, function (url) {
if (url.indexOf('@') != -1) {
return url;
}
return url.replace(webLinkPattern, "<a href=\"http://$&\" target=\"_blank\" onclick=\"preventDualEditing(event)\">$&</a>");
});