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