: Judith Flores
Cc: RHelp
Subject: Re: [R] Regular expression to define contents between parentheses
Instead of using .* use [^)]* so that you only get up to the next ) and also
it seems that you want to trim spaces so add space star at the beginning
and end:
gsub(" *\\([^)]*\\) *", &q
Instead of using .* use [^)]* so that you only get up to the next ) and also
it seems that you want to trim spaces so add space star at the beginning
and end:
gsub(" *\\([^)]*\\) *", "", myvector)
On Tue, Aug 25, 2009 at 4:17 PM, Judith Flores wrote:
> Hello dear R-helpers,
>
> I haven't been
Hi Judith,
This probably isn't the only way to do it, but:
gsub("\\(.*?\\)", "", myvector, perl=TRUE)
seems to do the trick.
The problem is that regular expressions are greedy, so you were matching
everything between the first and last parens, as you noticed. Putting
the question mark ther
to:r-help-boun...@r-project.org] On
Behalf Of Judith Flores
Sent: Tuesday, August 25, 2009 1:18 PM
To: RHelp
Subject: [R] Regular expression to define contents between parentheses
Hello dear R-helpers,
I haven't been able to figure out of find a solution in the R-help
archives about how t
Hello dear R-helpers,
I haven't been able to figure out of find a solution in the R-help archives
about how to delete all the characters contained in groups of parenthesis. I
have a vector that looks more or less like this:
myvector<-c("something (80 km/h, sd) & more (6 kg/L,sd)", "something
5 matches
Mail list logo