I am not sure what is the expected behavior for the removeChars function. It does not escape/quote its arguments, so the pattern [()] will be interpreted as [[()]] with the last bracket as not a proper regular expression. (As I remember any exception will result in missing values.) You can try the following: