unCapitalizedWords method
Finds and returns a list of words from the string that are uncapitalized (start with a lowercase letter).
This method splits the string into words and then filters out the words that start with a
lowercase letter.
The definition of a 'word' is determined by the words method of StringExtensions
.
Returns:
A List<String>? containing the uncapitalized words found in the string, or null
if no
uncapitalized words are found, or if the original string is empty.
Example:
'Find uncapitalized Words here'.unCapitalizedWords(); // Returns ['uncapitalized', 'here']
'CAPITALIZED WORDS'.unCapitalizedWords(); // Returns null
''.unCapitalizedWords(); // Returns null
Implementation
List<String>? unCapitalizedWords() => words()
?.where((String word) => word.isNotEmpty && word[0].isAllLetterLowerCase)
.toList()
.nullIfEmpty();