我怎样才能获得url,而不从这个字符串的双引号:我怎样才能得到我在一个双引号与正则表达式?
<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
我怎样才能获得url,而不从这个字符串的双引号:我怎样才能得到我在一个双引号与正则表达式?
<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
假设HTML字符串是在一个名为“regexp.html”
文件$ ruby -n -e 'm = $_.match(/(http[^"]+)/); puts m if m' < regexp.html
http://xxx/aaa/index.html
这只有在URL以“http”开头时才有效。
使用HTML解析器。 – Toto
awk'NR == 6 {print; exit}'a.html | grep [\“]。* [\”]。我用awk只是拿起我想要的线 – curious