1
我根本無法弄清楚這一點,並試圖一段時間。我需要一個正則表達式,將通過以下方式分析數據:解析這個或這個使用正則表達式
比方說我有下面的格式輸入:
www.google.com
www.google.com/
www.google.com/something
我需要一個正則表達式,它將分析上述三個URL(獨立)到最後的結果:
www.google.com
www.google.com
www.google.com
但是,它需要與他們的方式,是基於以下幾點:
Parse and return everything to the left of a "/" if one exists in the line
Parse and return the entire line if no "/" exists in the line
我是新來的正則表達式,所以雖然這可能很簡單,但我無法弄清楚。
當你說「a /的左邊」時,你的意思是第一個還是最後一個「/」? – fge 2011-12-16 11:41:37