2014-03-29 31 views
0

我:

<add key="IgnorePathRegex" value="^/Home/Ignore$|^/Ignore\.aspx$|^/Content/" /> 

我需要的值更改爲/Uploads/Logos。目前我認爲它是/Home/Ignore/Content/,但不完全確定。

+1

管道符號表示OR。目前你有三個完全不同的部分。你可以添加更多,如果你喜歡。 – Fattie

+0

檢查[this reference out](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – HamZa

回答

2

目前,它匹配下面:

/Home/Ignore 
/Ignore.aspx 
/Content/* (anything under /Context/ including /Context) 
+0

謝謝。我剛剛嘗試過一些在線測試人員,他們抱怨「/」未被轉義,因此我的正則表達式無效。它是否正確? – SamJolly

+0

取決於您使用的庫(或在線工具)。你的正則表達式可能是有效的.. – mesutozer

1

如果你想在/Uploads/Logos添加到列表中:

value="^/Home/Ignore$|^/Ignore\.aspx$|^/Content/|^/Uploads/Logos$" 

或者,如果你只想要/Uploads/Logos

value="^/Uploads/Logos$" 

答案,那就是在標題的問題:你的正則表達式有幾個路徑檢查哪些是與管道或(|

2

正則表達式的說明:

^/Home/Ignore$ # Match if the entire string is /Home/Ignore 
|    # or 
^/Ignore\.aspx$ # Match if the entire string is /Ignore.aspx 
|    # or 
^/Content/  # Match if the string starts with /Content/ 

^$anchors;如果你想添加另一個選項,只需附加|即可。