detectable_text_field icon indicating copy to clipboard operation
detectable_text_field copied to clipboard

Add the ability to reduce the RegExp matching

Open Ibtesam-Mahmood opened this issue 3 years ago • 1 comments

Currently, when a RegExp is passed into the detectable text field, it is used to discover all matches within the text.

final tags = detectionRegExp.allMatches(copiedText).toList();

detector.dart

However, I want to only match the first regexp within the text to highlight only the first mention of a @username. Is it possible to add a boolean to the detector to conditionally match the first or all matches to the RegExp.

final bool matchFirst;
...
final tags = matchFirst ? [detectionRegExp.firstMatch(copiedText)]
      : detectionRegExp.allMatches(copiedText).toList();

Ibtesam-Mahmood avatar Dec 05 '21 03:12 Ibtesam-Mahmood

I proposed a change for this in #30.

Ibtesam-Mahmood avatar Dec 05 '21 03:12 Ibtesam-Mahmood