我的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