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
i changed the expression a bit and it works in any language
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