Reputation: 303
I'm wanting to match a string exactly, for instance I have two expressions that I want to match independent of each other. Expressions are
/SignUpFor
/SignUpFor/ThankYou
The string "/SignUpFor" returns a match on the first expression which is correct; the string "/SignUpFor/ThankYou" returns a match on both.
How can I get "SignUpFor/ThankYou" just to match with the expression /SignUpFor/ThankYou
.
The reason I'm not just using "==" is that I have other expressions such as /TheLovelyBlog/Entry/([0-9]+)
These expression are stored in a database.
Upvotes: 3
Views: 9303
Reputation: 39284
If you start a regex with ^
, then the match must be from the start.
End the regex with $
to signal that the match must be until the end.
Upvotes: 3
Reputation: 2801
put a ^ at the start and a $ at the end http://msdn.microsoft.com/en-us/library/h5181w5w.aspx
Upvotes: 13