copyWith method
A default implementation of copyWith for RegExp.
This method is used to create a new RegExp with the same properties of the original, but with the given values replaced.
Example:
final regex = RegExp(r'(?<name>\w+)');
final newRegex = regex.copyWith(caseSensitive: false);
Implementation
RegExp copyWith({
String? pattern,
bool? multiLine,
bool? caseSensitive,
bool? unicode,
bool? dotAll,
}) {
return RegExp(
pattern ?? this.pattern,
multiLine: multiLine ?? isMultiLine,
caseSensitive: caseSensitive ?? isCaseSensitive,
unicode: unicode ?? isUnicode,
dotAll: dotAll ?? isDotAll,
);
}