trimStringRight method

String trimStringRight(
  1. String chars
)

Trims the characters given by chars from after String.

Stringの後からcharsで与えられた文字をトリムします。

final text = "__text___";
final trimed = text.trimString("_"); // "__text"

Implementation

String trimStringRight(String chars) {
  final pattern = chars.isNotEmpty ? RegExp("[$chars]+\$") : RegExp(r"\s+$");
  return replaceAll(pattern, "");
}