I am looking for a regex expression in JavaScript for the same use case as this post here: regex matching links without <a> tag
My goal is to transform a string such as
Here is a link https://www.somewebsite.com/ here is a link already in an a tag <a href="https://www.somewebsite.com/">https://www.somewebsite.com/</a>
To
Here is a link <a href="https://www.somewebsite.com/">https://www.somewebsite.com/</a> here is a link already in an a tag <a href="https://www.somewebsite.com/">https://www.somewebsite.com/</a>
There are many regex examples for a url, but I am not sure how to add an "and" condition for the url match not being in an <a> tag. I have only found examples so far for php or python, but not JS.
Thank you!
addan and condition" - you could use a negitive look ahead to confirm that the matched pattern (the link) in not followed by a</a>tag. Another approach would be to use a negated character set to tell the regex engine to match everything until a<is encountered.