iAteABug_And_iLiked_it
iAteABug_And_iLiked_it

Reputation: 3795

How to exclude a character in Regex

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

Upvotes: 1

Views: 86

Answers (1)

anubhava
anubhava

Reputation: 784998

You need to use negative lookahead like this:

(?!.*?<)

Upvotes: 1

Related Questions