I need to test a url that it does not end with .asp
So test
, test.html
and test.aspx
should match, but test.asp
should not match.
Normally you'd test if the url does end with .asp and negate the fact that it matched using the NOT operator in code:
if(!regex.IsMatch(url)) { // Do something }
In that case the regular expression would be \.asp$
but in this case I need the regular expression to result in a match.
Thank you!
Background: I need to use the regular expression as a route contraint in the ASP.NET MVC RouteCollection.MapRoute
extension method. The route needs to match all controllers but it should fall through when the controller in the url ends with .asp