我正在學習正則表達式。我有一個很簡單的問題:將url路徑中的lang更改爲子域的正則表達式
我的php.I內容的一長串想所有的地方轉換,它說:
http://www.example.com/en/rest-of-url
到
http://en.example.com/rest-of-url
有人能幫助我和這個?我想我使用preg_replace這個?
獎勵:如果你有一個好網站的鏈接,它解釋瞭如何在正則表達式中這樣做最簡單的事情,請張貼它。我所看到的每個正則表達式資源都非常快速(甚至維基百科文章)。
您應該使用不同的字符作爲分隔符而不是'/',它使正則表達式更易於理解。 – DisgruntledGoat