Learn R Programming

qdap (version 1.3.5)

rm_url: Remove/Replace URLs

Description

Remove/Replace URLs from a string.

Usage

rm_url(text.var, trim = TRUE, clean = TRUE,
  pattern = "(http[^ ]*)|(www\\.[^ ]*)", replacement = "", ...)

Arguments

text.var
The text variable.
trim
logical. If TRUE removes leading and trailing white spaces.
clean
trim logical. If TRUE extra white spaces and escaped character will be removed.
pattern
A character string containing a regular expression (or character string for fixed = TRUE) to be matched in the given character vector.
replacement
Replacement for matched pattern.
...
Other arguments passed to gsub.

Value

  • Returns a character string with URLs removed.

See Also

gsub

Examples

Run this code
x <- " I like www.talkstats.com and http://stackoverflow.com"
rm_url(x)
rm_url(x, replacement = '<a href="\\1" target="_blank">\\1</a>')

Run the code above in your browser using DataLab