escapeRegExp function

String escapeRegExp(
  1. String string
)

Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "", "", "{", "}", and "|" in string.

Implementation

String escapeRegExp(String string) {
  return string.replaceAll(RegExp(r'[\\^$.*+?()[\]{}|]'), r'\\$&');
}