------
>> Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry
>> Indiana University School of Medicine
>>
>> 15032 Hunter Court, Westfield, IN 46074
>>
>> (317) 490-5129 Work, & Mobile & VoiceMail
2009 9:28 AM
To: William Dunlap; r-help@r-project.org
Subject: Re: [R] help with regular expressions in R
Well, I guess I'm not quite there yet. What I gave earlier was a
simplified example, and did not accurately reflect the complexity of the
task.
***
On Thu, Aug 20, 2009 at 11:39 AM, William Dunlap wrote:
>
> > -----Original Message-
> > From: r-help-boun...@r-project.org
> > [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Kimpel
> > Sent: Thursday, August 20, 2009 8:31
Mark,
Try this:
> myCharVec
[1] "[the rain in spain]" "(the rain in spain)"
> gsub("\\[.*\\]", "", myCharVec)
[1] """(the rain in spain)"
You need two backslashes to "escape" the square brackets. The regular
expression "\\[.\\]" translates to "a [ followed by 0 or more insta
How about this:
> myCharVec <- c("[the rain in spain]", "(the rain in spain)")
> gsub('\\[.*\\]', '', myCharVec)
[1] """(the rain in spain)"
>
you had "*." when you should have ".*"
On Thu, Aug 20, 2009 at 11:30 AM, Mark Kimpel wrote:
> I'm having trouble achieving the resul
I'm having trouble achieving the results I want using a regular expression.
I want to eliminate all characters that fall within square brackets as well
as the brackets themselves, returning an "". I'm not sure if it's R's use of
double slash escapes or something else that is tripping me up. If I on
6 matches
Mail list logo