我怎樣才能獲得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