getWords method

List<String> getWords()

Extracts all individual words from the string based on word boundaries.

This is useful for natural language processing or extracting keywords.

@returns A List<String> containing all the words found.

Example:

final sentence = 'The Flutter app is amazing!';
print(sentence.getWords()); // ["The", "Flutter", "app", "is", "amazing"]

Implementation

List<String> getWords() => RegExp(r'\b\w+\b')
    .allMatches(this)
    .map((match) => match.group(0)!)
    .toList();