REGEX...
-
Hi.
I have used regex twice before, I dont like it and to be honest dont fully understand it, but as this is only the third time in 5 years that I have needed it I dont plan on learning everything about it!
Basically what I need to do is match any string EXCEPT default, this is for a URL rewriting module which is part of a site that I have inherited, I now need the default page to be excluded.
the current rule is: P>
([^/]*)\.aspx
which matches test.aspx|default.aspx|Somethingelse.aspx etc, I simply want this to continue, but without default.aspx being matched..
Any help appreciated - even point me at a good site... as long as I dont have to spend ages learning regex, this will most likley be a one off...
Thanks
-
Hmmmnn after a bit of fiddling I came up with this: ^(?!\bdefault\b[^/])([^.aspx]*).*$ Any thoughts? It seems to work, but thats more luck/brute force and ignorance than anything else... Thanks
[EDIT]
Spoke too soon courses.aspx gets matched as cour.aspx... wtf???
-
I'd say you need a negative lookbehind. Try this:
([^/]*(?<!default))\.aspx