getWords method
get word list from string input assume that words are separated by special characters or by camel case
Implementation
List<String> getWords() {
final input = this;
final StringBuffer buffer = StringBuffer();
final List<String> words = [];
final bool isAllCaps = input.toUpperCase() == input;
for (int i = 0; i < input.length; i++) {
final String currChar = input[i];
final String? nextChar = i + 1 == input.length ? null : input[i + 1];
if (_symbolSet.contains(currChar)) {
continue;
}
buffer.write(currChar);
final bool isEndOfWord = nextChar == null ||
(!isAllCaps && _upperAlphaRegex.hasMatch(nextChar)) ||
_symbolSet.contains(nextChar);
if (isEndOfWord) {
words.add(buffer.toString());
buffer.clear();
}
}
return words;
}