Search code examples
regexurlregular-language

Exclude part of the string with regex


I'm quite bad with regex, and I'm looking to match a criteria. This is a regex expression that should go emmbed into the url for a firewall, so It will block any url that is not like the list at the end.

This is what Im currently using but its not working:

http://www.youtube.com/(*.*)list=UUFwtOm4N5djdcuTAlNIWJaQ

This is the example url (to be blocked):

http://www.youtube.com/watch?NR=1&feature=fvwp&v=P1b5VY_Bp_o&list=UUFwtOm4N5djdcuTAlNIWJaQ

I'm trying to make a regex that will Success fully match when NR=1 or feature=fvwp are NOT present, I asume I can do it like this: (?!^feature=fvwp$) but the v= and list=UUFwtOm4N5djdcuTAlNIWJaQ are allowed.

Also the v= should be limited to any character (uppercase and lowercase) and 11 length, I assume its: /^[a-z0-9]{11}$/

How can I build all that together and make it work so it would allow and match only on this urls excluding from allowing the previous criterias that I explained:

http://www.youtube.com/watch?v=4eK_RWpTgcc&feature=BFa&list=UUFwtOm4N5djdcuTAlNIWJaQ

http://www.youtube.com/watch?v=TLRl85TJwZM&feature=BFa&list=UUFwtOm4N5djdcuTAlNIWJaQ

http://www.youtube.com/watch?v=QEV9yqrpxkc&feature=BFa&list=UUFwtOm4N5djdcuTAlNIWJaQ

Solution

  • Can you block based on matching by regex? If so, just use (.*)www\.youtube\.com/watch\?NR=1&feature=fvwp and block whatever matches that.