Question

I have this Regex expression

UriPatternToMatch= new Regex(@"(href|src)=""[\d\w\/:#@%;$\(\)~_\?\+\-=\\\.&]*", 
RegexOptions.Compiled | RegexOptions.IgnoreCase)

This is working fine to pickup all URLS including http,ftp and others , but it picks up text within "&lt" special characters as URL too

for example it will wrongly pick up the text below as a URL too ( adding a photo instead of text below)

snapshot

I believe something like ^&lt is what is needed , but where do I add it ?

Thanks

Was it helpful?

Solution

You need to use negative lookahead like this:

(?!.*?<)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top