我的HTML代码中的R类似下面的部分中的R卸下HTML代码:使用GSUB
"</a> <img src=\"images/arrow_orange.gif\" width=\"8\" height=\"12\"> <a href=\"group.php?g=1\">XXXX</a> <img src=\"images/arrow_orange.gif\" width=\"8\" height=\"12\"> <a href=\"category.php?c=100050\">YYYY</a> <img src=\"images/arrow_orange.gif\" width=\"8\" height=\"12\"> <a href=\"category.php?c=100050&brand=Motorola\">ZZZZ</a> <img src=\"images/arrow_orange.gif\" width=\"8\" height=\"12\">AAAA"
我想使用GSUB以除去不想要的HTML代码,以便输出将是:
XXXX YYYY ZZZZ AAAA
我试过<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>
如图所示here但是失败了,为什么?
我该如何在R中做到这一点?谢谢。
它可能是清洁提取使用'XML'库从HTML代码名称和'xPath'查询。如果你发布了一个包含html代码的网页的链接,那么有很多人可以向你提供关于如何提取所需信息的指针。 – Ramnath
要小心... http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Iterator
这个问题和其他应该合并? http://stackoverflow.com/questions/7057374/remove-anything-within-a-pair-of-parenthesis-using-gsub-in-r – Iterator