findMatchingTextStyle<T> static method

RegexPatternTextStyle<T>? findMatchingTextStyle<T>(
  1. String textPart,
  2. List<RegexPatternTextStyle<T>>? partStyleList
)

Implementation

static RegexPatternTextStyle<T>? findMatchingTextStyle<T>(
  String textPart,
  List<RegexPatternTextStyle<T>>? partStyleList,
) {
  if (textPart.isEmpty || partStyleList == null || partStyleList.isEmpty) {
    return null;
  }

  for (final style in partStyleList) {
    final compiledPattern = _compiledPatternCache[style] ??= RegExp(
      style.regexPattern,
      caseSensitive: style.caseSensitive,
      multiLine: style.multiLine,
    );

    if (compiledPattern.hasMatch(textPart)) {
      return style;
    }
  }

  return null;
}