escape method
- String text
Creates regular expression syntax that matches text
.
If text
contains characters that are meaningful in regular expressions, the resulting regular expression will match those characters literally. If text
contains no characters that have special meaning in a regular expression, it is returned unmodified.
The characters that have special meaning in regular expressions are: (
, )
, [
, ]
, {
, }
, *
, +
, ?
, .
, ^
, $
, |
and \
.
This method is mainly used to create a pattern to be included in a larger regular expression. Since a String is itself a Pattern which matches itself, converting the string to a regular expression isn't needed in order to search for just that string.
Implementation
external static String escape(String text);
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/RegExp/escape.html