开发者

C# RegEx Match Pattern Exactly

I'm wanting to match a string exactly, for instance I have two expressions that I want开发者_JAVA技巧 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.


put a ^ at the start and a $ at the end http://msdn.microsoft.com/en-us/library/h5181w5w.aspx


Add ^ and $ in the beginning and in the end of your expressions


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜