Dart RegExp isUnicode
Syntax & Examples
RegExp.isUnicode property
The `isUnicode` property in Dart's `RegExp` class determines whether the regular expression is in Unicode mode.
Syntax of RegExp.isUnicode
The syntax of RegExp.isUnicode property is:
bool isUnicode
This isUnicode property of RegExp whether this regular expression is in Unicode mode.
Return Type
RegExp.isUnicode returns value of type bool
.
✐ Examples
1 Using Unicode mode
In this example,
- We create a `RegExp` object named `pattern` with the pattern 'hello' and unicode set to true.
- We print the value of `isUnicode` property, which should be true indicating that the regular expression is in Unicode mode.
Dart Program
void main() {
RegExp pattern = RegExp('hello', unicode: true);
print(pattern.isUnicode);
}
Output
true
2 Not using Unicode mode
In this example,
- We create a `RegExp` object named `pattern` with the pattern 'hello' and unicode set to false.
- We print the value of `isUnicode` property, which should be false indicating that the regular expression is not in Unicode mode.
Dart Program
void main() {
RegExp pattern = RegExp('hello', unicode: false);
print(pattern.isUnicode);
}
Output
false
Summary
In this Dart tutorial, we learned about isUnicode property of RegExp: the syntax and few working examples with output and detailed explanation for each example.