finish static method
Caps value with a single instance of cap.
Implementation
static String finish(String value, String cap) {
if (cap.isEmpty) return value;
final String stripped = value.replaceAll(
RegExp(RegExp.escape(cap) + r'+$'),
'',
);
return '$stripped$cap';
}