Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从该字符串中获取没有双引号的 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”开头时才有效。
您可以使用正则表达式模式http:[^"]+
http:[^"]+