single static method
Replaces specific characters in the input string with the specified replacement.
Parameters:
value
: The input string to perform replacements on.replacement
: The string to replace the matched characters with.regex
: A list of regular expressions to match characters for replacement.
Example:
String result = Replacement.single("Hello, World!", "-", ["!"]);
print(result); // Output: 'Hello, World-'
Implementation
static String single(
String value,
String replacement,
List<String>? regex,
) {
if (regex != null && regex.isNotEmpty) {
for (String reg in regex) {
value = value.replaceAll(reg, replacement);
}
}
return value;
}