我要尋找一個正則表達式匹配以下4個例(抓住ID的,所以我可以重新寫入的網址)正則表達式可選組
http://localhost/gallery/test-name/123456
http://localhost/gallery/test-name/123456/
http://localhost/gallery/test-name/123456/video-name/159
http://localhost/gallery/test-name/123456/video-name/159/
當前正則表達式是下面的,但其不斂IDS正確地在所有情況下。那裏的任何專家都知道我做錯了什麼?
^(.*)/gallery/(.*)/([0-9]{1,15})(/)?((.*)/([0-9]{1,15})(/)?)?
哪種編程語言? – Gerrat
你爲什麼不把字符串分割成'/'? – halex