escapeRegExp function Null safety
- String string
Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "", "
", "{", "}", and "|" in string.
Implementation
String escapeRegExp(String string) {
return string.replaceAll(RegExp(r'[\\^$.*+?()[\]{}|]'), r'\\$&');
}