mystring <- "abc[de" gsub("[\\[\\]$]","",mystring, perl = TRUE) gsub("[][$]","",mystring)