Send expression to website return dynamic result (picture)

纵饮孤独 提交于 2019-12-04 06:21:18

Try something like this:

Query <- function(searchPattern, browse = TRUE) {
  finalURL <- paste0("http://www.regexper.com/#", 
         URLencode(searchPattern))
  if (isTRUE(browse)) browseURL(finalURL)
  else finalURL
}

x <- "\\s*foo[A-Z]\\d{2,3}"
Query(x)             ## Will open in the browser
Query(x, FALSE)      ## Will return the URL expected
# [1] "http://www.regexper.com/#%5cs*foo[A-Z]%5cd%7b2,3%7d"

The above function simply pastes together the web URL prefix ("http://www.regexper.com/#") and the encoded form of the search pattern you want to query.

After that, there are two options:

  • Open the result in the browser
  • Just return the full encoded URL
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!