Hello,

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)"
>StrNoBrackets<-cleanBetweenBrackets(Str)
>StrNoBrackets
[1]  "The cat is crazy "

Assistance would be appreciated,

Audrey

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to