findAll static method

List<int> findAll(
  1. String haystack,
  2. String needle, {
  3. bool wholeWord = false,
})

Implementation

static List<int> findAll(String haystack, String needle, {bool wholeWord = false}) {
  final List<int> hits = <int>[];
  if (needle.isEmpty) return hits;
  int from = 0;
  while (true) {
    final int index = haystack.indexOf(needle, from);
    if (index < 0) break;
    if (!wholeWord || _isWordBoundary(haystack, index, needle.length)) hits.add(index);
    from = index + 1;
  }
  return hits;
}