2013-01-17 36 views
1

我想檢查Request.RawURL字符串是否與特定結構相匹配。檢查url是否與特定結構匹配

要檢查的結構將是:

/health/<integer>/<string> 

例如

/health/301/personal-trainers-at-work 

如果原始url匹配這個結構,我希望表達式的計算結果爲true。

+0

這最後一個值是一個字符串或最後一個值是不是int? 「123」是一個字符串例如(可以轉換爲int) – Magnus

+0

@ msmucker0527什麼都沒有,因爲我不知道從哪裏開始:) @ Magnus:正確,最後一個值是一個字符串,它也可能包含數字 – Flo

回答

3

使用這個表達式/health/\d+/[\w-]+

/health/ const srting  
\d+  1 or more integers  
/  const srting  
[\w-]+ 1 or more alphanumeric characters _ or - 
+0

謝謝。如何在代碼隱藏中在VB.NET中測試這個正則表達式? – Flo

+1

http://msdn.microsoft.com/en-us/library/sdx2bds0.aspx –

相關問題