Dart RegExp isMultiLine
Syntax & Examples
RegExp.isMultiLine property
The `isMultiLine` property in Dart's `RegExp` class determines whether the regular expression matches multiple lines.
Syntax of RegExp.isMultiLine
The syntax of RegExp.isMultiLine property is:
bool isMultiLine
This isMultiLine property of RegExp whether this regular expression matches multiple lines.
Return Type
RegExp.isMultiLine returns value of type bool
.
✐ Examples
1 Single Line Matching
In this example,
- We create two regular expressions, `regex1` and `regex2`, with patterns 'hello' and '^hello' respectively.
- We print the `isMultiLine` property of each regex.
Dart Program
void main() {
RegExp regex1 = RegExp('hello');
RegExp regex2 = RegExp('^hello', multiLine: true);
print('regex1.isMultiLine: ${regex1.isMultiLine}');
print('regex2.isMultiLine: ${regex2.isMultiLine}');
}
Output
regex1.isMultiLine: false regex2.isMultiLine: true
2 Single Line Matching
In this example,
- We create a regular expression `regex` with pattern '^Hello' and set the `multiLine` flag to false.
- We print the `isMultiLine` property of the regex.
Dart Program
void main() {
RegExp regex = RegExp('^Hello', multiLine: false);
print('regex.isMultiLine: ${regex.isMultiLine}');
}
Output
regex.isMultiLine: false
3 Single Line Matching
In this example,
- We create a regular expression `regex` with pattern 'World' and set the `multiLine` flag to false.
- We print the `isMultiLine` property of the regex.
Dart Program
void main() {
RegExp regex = RegExp('World', multiLine: false);
print('regex.isMultiLine: ${regex.isMultiLine}');
}
Output
regex.isMultiLine: false
Summary
In this Dart tutorial, we learned about isMultiLine property of RegExp: the syntax and few working examples with output and detailed explanation for each example.