Greetz人。Shell相當於PHP的preg_replace()
我正在尋找一種方法來執行相同的東西,而不是PHP的preg_replace()(在shell腳本中搜索與正則表達式匹配的文本並替換它)。
因此,請考慮以下文件。
<a href="http://example.com/">Website #1</a>
<a href="http://example.net/">Website #2</a>
<a href="http://example.org/">Website #3</a>
而且我要得到這個:
http://example.com/
http://example.net/
http://example.org/
有沒有辦法做到這一點?謝謝。
您的文字從你的例子不同。你想提取你的字符串的一部分(如你的例子)還是你想實際取代它? – plundra 2010-12-20 15:18:19
此外,[不要使用正則表達式解析HTML](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)(in一般)。 – delnan 2010-12-20 15:19:11
如果你說,「所以,考慮下面的文件。」,那麼人們會認爲這是數據。下次做個正確的問題。 – Anders 2010-12-20 15:20:15