extractNumbers static method

List<int> extractNumbers(
  1. String text
)

Extract numbers from string

text - The text to extract numbers from Returns list of numbers found

Implementation

static List<int> extractNumbers(String text) {
  final regex = RegExp(r'\d+');
  return regex.allMatches(text).map((match) => int.parse(match.group(0)!)).toList();
}