Home > Net >  Regex issue with dart
Regex issue with dart

Time:12-29

I'm writing a method that uses a regex to return the first match in a list of strings

  String getMatch(String sentence) {
    for (String word in sentence.split(' ')) {
      if (regex.hasMatch(word)) {
        return word;
      }
    }
    return '';
  }

regex: RegExp('/\d .\d F/gi') (from enter image description here

i changed the expression a bit and it works in any language

enter image description here

CodePudding user response:

Fixed by changing regex to RegExp(r'\b\d .\d F\b', caseSensitive: false) answer given by The fourth bird in the comments

  • Related