findThinkingTriggerPositions method

List<({int end, int start, String word})> findThinkingTriggerPositions(
  1. String text
)

Find positions of "ultrathink" keyword in text (for UI highlighting).

Implementation

List<({String word, int start, int end})> findThinkingTriggerPositions(
  String text,
) {
  final positions = <({String word, int start, int end})>[];
  final matches = RegExp(
    r'\bultrathink\b',
    caseSensitive: false,
  ).allMatches(text);
  for (final match in matches) {
    positions.add((
      word: match.group(0)!,
      start: match.start,
      end: match.end,
    ));
  }
  return positions;
}