Reputation: 86987
this one is really easy.
I'm trying to create a Regular Expression that will result in a Successful Match when against the following text
/default.aspx?
So i tried the following...
^/default.aspx$
and it's failing to match it.
Can someone help, please?
(i'm guessing i'm screwing up becuase of the \
and the ?
in the input expression).
Upvotes: 0
Views: 220
Reputation: 17651
The problem is in the .
(dot), which is a wildcard,
You must escape it like \.
.
Also, Because there is a ?
at the end of URL and $
(end-of-input) is in the regexp, therefore, it does not match.
The correct regexp should be ^/default\.aspx(\?.*)?$
Upvotes: 2
Reputation: 383886
Maybe something like this is more appropriate:
^/default\.aspx(\?.*)?$
This will match default.aspx
, with an optional ?whatever-else-that-comes-after
.
Upvotes: 1
Reputation: 1256
The $ at the end of ^/default.aspx$ means 'match the end of the string', but the string you're searching ends with '?'.
Upvotes: 1