[R] Fwd:

Audrey Riddell audreykaspi at gmail.com
Tue Sep 6 12:56:09 CEST 2016


I have been able to figure this out using \\ (two back slashes for escape)
Working R code for what I wanted is...

cleanBetweenBrackets <- function(String)
  { return(gsub("\\(.*?\\)", "", String))}

I thought I had tried that (the \\) before I emailed the list. Please
ignore my previous email.

Sorry for any inconvenience caused.


---------- Forwarded message ----------
From: Audrey Riddell <audreykaspi at gmail.com>
Date: Tue, Sep 6, 2016 at 4:56 PM
To: r-help at r-project.org


I am trying to remove brackets and the text contained in brackets. I tried
to do a user defined formula... my attempt at this is pasted below.

cleanBetweenBrackets <- function(String)
  { return(gsub("\(.*?\)", "", String))}

 I keep getting errors (namely that there is an unrecognised escape
character in the string). I have looked at regex forums a bit, but cant
figure this out.

I want the above formula to be able to produce the following result

>Str<-"The cat is crazy (but not too crazy)"
[1]  "The cat is crazy "

Assistance would be appreciated,


	[[alternative HTML version deleted]]

More information about the R-help mailing list