[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] yet another regular expression
From: Jim Lemon <jim () bitwrit ! com ! au>
Date: 2014-06-30 23:48:41
Message-ID: 11901088.FbOoqmIQAC () localhost ! localdomain
[Download RAW message or body]
On Mon, 30 Jun 2014 11:13:18 PM Jim Lemon 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.
>
Hi again,
Sorry, but my "minimal reproducible example" was apparently
misleading. "value1" and "value2" are not fixed strings, but varying
numbers. After a night's sleep I solved the problem using strsplit(), which
gave me a big list of strings that I could process without wearing out the
"\" key. Thanks for the suggestions.
Jim
______________________________________________
R-help@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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic