SventoryMang
SventoryMang

Reputation: 10478

Regex to match text in URL only as the last part?

I am trying to construct a regular expression that will match the following URL:

www.mydomain.com/testPhrase

but NOT match

www.mydomain.com/directory/stuff/morestuff/testPhrase/index.aspx?blah=foo

for an IIS URL Rewrite Rule.

I started with ^.*testPhrase but that matches both. What is the regex syntax to say only match if there is nothing after testPhrase but there can be anything before it?

Upvotes: 0

Views: 158

Answers (1)

Dave C
Dave C

Reputation: 441

Why not use ^.*testPhrase$ - that would ensure that testPhrase is always at the very end.

Upvotes: 3

Related Questions