有沒有辦法將下面的所有內容與一個正則表達式匹配?如果不是,那麼幹淨的方法是什麼?將URL與特定數量的正斜槓匹配
/resources/$
/resources/type$
/resources/type/$
/resources/category$
/resources/category/$
/resources/anything here that includes up to 1 slash and ends with that slash
以下應不匹配,因爲something
存在,:
/resources/type/something
/resources/category/something
謝謝。我調整了也匹配首都,數字和破折號。 '^ \ /資源(\/[A-ZA-Z0-9 - ] * \ /)?$' – 2012-08-11 11:40:22