[R] Regular expression
arun
smartpink111 at yahoo.com
Tue Jan 15 22:52:12 CET 2013
HI,
vec1<-"'asd'f"
vec2<-'"asd"f'
gsub("[\"]","",vec2)
#[1] "asdf"
gsub("[']","",vec1)
#[1] "asdf"
A.K.
----- Original Message -----
From: Christofer Bogaso <bogaso.christofer at gmail.com>
To: r-help <r-help at r-project.org>
Cc:
Sent: Tuesday, January 15, 2013 4:38 PM
Subject: [R] Regular expression
Hello again,
I am having a problem on Regular expression. Let say I have following code:
> gsub("[',]", "", "'asd'f")
[1] "asdf"
This is perfect. However I am having problem if I include "" (i.e. the
double quote) in the first argument as the pattern search:
> gsub("[',"]", "", "'asd'f")
Error: unexpected ']' in "gsub("[',"]"
What is the right way to include the 'double quote' in the search field?
Thanks for your help.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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
mailing list