[R] regular expression in gsub() for strings with leading backslash
murdoch.duncan at gmail.com
Sat Apr 30 03:07:37 CEST 2011
On 29/04/2011 7:41 PM, Miao wrote:
> Can anyone help on gsub() in R? I have a string like something below, and
> wanted to delete all the strings with leading backslash, including "\xa0On",
> "\023, "\xab", and many others. How should I write a regular expression
> pattern in gsub()? I don't care how many characters following backslash.
If those are R strings, none of them contain a backslash. In R, a
backslash would always be printed as \\.
\x is the introduction to a hexadecimal encoding for a character; the
next two characters show the hex digits. So your first string contains
a single character \xa0, the third one contains \xab, and so on.
The \023 is an octal encoding for a single character.
> txt<- "Is This Thing\xa0On? http://bit.ly/jAbKem wait \023 for people \xab
> and be patient :"
> Thanks in advance,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help