我想http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
用它的域(“Hello world stackoverflow.com”)替换字符串(“Hello world”)中的URL。
到目前为止,我能够用某个常量值而不是 URL 的域来识别和替换 URL:
x <- "Hello world http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example"
gsub("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", "URL", x)
它高度赞赏任何帮助。