blacklist function

String blacklist (
  1. String str,
  2. String chars
)

remove characters that appear in the blacklist.

The characters are used in a RegExp and so you will need to escape some chars.

Implementation

String blacklist(String str, String chars) {
  return str.replaceAll(new RegExp('[' + chars + ']+'), '');
}