[R] yet another regular expression
arun
smartpink111 at yahoo.com
Mon Jun 30 17:47:06 CEST 2014
Hi Jim,
May be this helps:
library(stringr)
paste(str_extract_all(initString, perl('(?<=\\:)[[:alnum:]]+,?'))[[1]],collapse="")
#[1] "value1,value2"
A.K.
On Monday, June 30, 2014 9:58 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
Hi all,
I have managed, with the help of glob2rx() to get two parts of a text
manipulation working. I have successfully gotten rid of the first and
second bits, but I have hit the wall trying to get rid of the last bit. Here's
an example:
initString<-
"\"Delete this\":value1,\"Delete this too\":value2},Delete last bit"
sub("\"Delete this too\":","",
sub(glob2rx("*this\":*"),"",initString),fixed=TRUE)
This gives me:
[1] "value1,value2},Delete last bit"
and glob2rx("},*") just won't get rid of the last bit. I throw myself upon
the mercy of the regular expression gurus.
Jim
______________________________________________
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