2

I have been using this regex for checking urls.

((?:href|src)=["']?)?((https?:\/\/(?:www\.)?|www\.)[a-z0-9][^@]*?)(?=&quot;|&#x27;|&lt;|[\s"'<]|$)

However, this matches urls enclosed in brackets Ex: (www.x.xom) (according to the regex, only the end bracket because there are cases where there are brackets inside a url). How do I write a regex so as to ignore the outer enclosing brackets??

Strings to be matched: (www.xyz.com) - only the url and www.xyz.com?query=(abc) - the entire string and (www.abc.com?q=(params)) - the string enclosed. Existing regex has a fault where if the string is (www.xyz.com) - it matches www.xyz.com).

Mohan Krishnan
  • 353
  • 3
  • 16

0 Answers0