countOccurrence method

int countOccurrence(
  1. String string
)

Counts the number of occurrences of a substring within this string.

@param string The substring to count. @return The number of occurrences of the substring.

Implementation

int countOccurrence(String string) =>
    isEmpty ? 0 : RegExp(string).allMatches(this).length;