cleanse method

String cleanse(
  1. String text, {
  2. bool ignoreCase = true,
})

Implementation

String cleanse(String text, {bool ignoreCase = true}) {
  String cleaned = this;

  // Replace text with an empty string, respecting case sensitivity
  if (ignoreCase) {
    cleaned = cleaned.replaceAll(RegExp(text, caseSensitive: false), '');
  } else {
    cleaned = cleaned.replaceAll(text, '');
  }

  // Remove colons and trim whitespace
  cleaned = cleaned.replaceAll(':', '').trim();

  return cleaned;
}