【发布时间】:2012-10-12 13:53:41
【问题描述】:
如何从该字符串中获取不带双引号的 url:
<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
【问题讨论】:
-
awk 'NR==6{print;exit}' a.html | grep [\"].*[\"] 。我用 awk 来接我想要的线路
如何从该字符串中获取不带双引号的 url:
<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
【问题讨论】:
您可以使用正则表达式模式http:[^"]+
【讨论】:
grep --h
假设 html 字符串在一个名为“regexp.html”的文件中
$ ruby -n -e 'm = $_.match(/(http[^"]+)/); puts m if m' < regexp.html
http://xxx/aaa/index.html
仅当 url 以“http”开头时才有效。
【讨论】: