isUnicode property Null safety

bool isUnicode
@Since("2.4")

Whether this regular expression is in Unicode mode.

In Unicode mode, UTF-16 surrogate pairs in the original string will be treated as a single code point and will not match separately. Otherwise, the target string will be treated purely as a sequence of individual code units and surrogates will not be treated specially.

In Unicode mode, the syntax of the RegExp pattern is more restricted, but some pattern features, like Unicode property escapes, are only available in this mode.

var regExp = RegExp(r'^\p{L}$', unicode: true);
print(regExp.hasMatch('a')); // true
print(regExp.hasMatch('b')); // true
print(regExp.hasMatch('?')); // false
print(regExp.hasMatch(r'p{L}')); // false

regExp = RegExp(r'^\p{L}$', unicode: false);
print(regExp.hasMatch('a')); // false
print(regExp.hasMatch('b')); // false
print(regExp.hasMatch('?')); // false
print(regExp.hasMatch(r'p{L}')); // true

Implementation

@Since("2.4")
bool get isUnicode;