-1

この文字列から二重引用符なしで URL を取得するにはどうすればよいですか:

<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
4

2 に答える 2

0

正規表現パターンを使用できますhttp:[^"]+

于 2012-10-12T14:02:11.130 に答える
0

HTML文字列が「regexp.html」というファイルにあると仮定します

$ ruby -n -e 'm = $_.match(/(http[^"]+)/); puts m if m' < regexp.html 
http://xxx/aaa/index.html

これは、URL が「http」で始まる場合にのみ機能します。

于 2012-10-12T15:10:05.413 に答える