Omniferum Posted November 5, 2010 Report Share Posted November 5, 2010 I've been trying to find a way to exclude a specific word from my regex matches, in this case the word source. My current 'attempt' has only found to be working if the word source or src is found to happen right BEFORE the extension. I assume it is because of the characters in the square brackets? Either way I was just curious if anyone could just spot what I needed doing and give me the (no doubt) 4 extra characters required to make it exclude matches with a specified word. http[^'"]+64[^'"]+7z Now if I do http[^'"]+64[^'"source]+7z It will work, only if the filename ends like vrasr444source.7z I obviously want it to apply to the entire match, not just the position. Link to comment Share on other sites More sharing options...
shawn Posted November 5, 2010 Report Share Posted November 5, 2010 Actually, the way that regex will work is to eliminate any URL where any of the characters "ceorsu" appear between "64" and "7z". The [^] pattern excludes those characters, NOT in any specific order/sequence. Simple regex really isn't good for excluding long strings/sequences like that. Some implementations (this one should) provide what's called "negative lookahead", which effectively excludes a string from a pattern. The following will capture a string that does NOT contain "IgnoreMe". (?!IgnoreMe) http://msdn.microsoft.com/en-us/library/ms972966.aspx Link to comment Share on other sites More sharing options...
Omniferum Posted November 5, 2010 Author Report Share Posted November 5, 2010 Sadly enough there was no way I was able to get the suggestion to work. Again i'm not great on syntax but I looked at the link to try some other lookaround processing but still ended up with not much. Link to comment Share on other sites More sharing options...
Tomorrow Posted November 5, 2010 Report Share Posted November 5, 2010 Bit offtopic but thanks for the link.I finally got somewhere to start.Just made my first regex.Please don´t laugh because i felt like winning a jackpot when i got this working finally : .{0,75} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now