【发布时间】:2013-08-22 05:59:06
【问题描述】:
我有一些看起来像这样的 HTML:
<ul><li><a href="http://www.website.com/index.aspx" target="_blank">Website</a></li>
<li><a href="http://website.com/index.html" target="_blank">Website</a></li>
<li><a href="http://www.website-with-dashes.org" target="_blank">Website With Dashes</a></li>
<li><a href="http://website2.org/index.htm" target="_blank">Website 2</a></li>
<li><a href="http://www.another-site.com/">Another Site</a></li>
使用
m<-regexpr("http://\\S*/?", links, perl=T)
links<-regmatches(links, m)
获取链接,但其中带有破折号的链接被截断如下:
http://www.website.com/index.aspx
http://website.com/index.html
http://www.website
http://website2.org/index.htm
http://www.another-site.com/
我认为 /S 匹配任何非空格。怎么回事?
【问题讨论】:
-
我无法复制您的问题。如果我用
\"替换",这样我就可以用readLines导入文本,一切都会按您的预期进行。