mergeRegexPatterns static method
Merges multiple regex patterns from annotations
Implementation
static RegExp? mergeRegexPatterns(List<FitAnnotation>? annotations) {
if (annotations == null || annotations.isEmpty) {
return null;
} else if (annotations.length == 1) {
return annotations[0].regExp;
}
final nonCapturingGroupPattern = RegExp(r'\((?!\?:)');
return RegExp(
annotations
.map(
(a) =>
'(${a.regExp.pattern.replaceAll(nonCapturingGroupPattern, '(?:')})',
)
.join('|'),
);
}