removeLastAny method

String removeLastAny(
  1. List<String?> patterns
)

Continuously removes from the end of the String, any match in patterns.

Example

String s = "esentisfs12".removeLastAny(["12","s","ng","f",]); // returns "esentis";

Implementation

String removeLastAny(List<String?> patterns) {
  var from = this;
  if (from.isNotBlank) {
    for (var pattern in patterns) {
      if (pattern != null && pattern.isNotEmpty) {
        while (from.endsWith(pattern)) {
          from = from.removeLast(pattern.length);
        }
      }
    }
  }
  return from;
}