int count(String value, [bool caseSensitive = true]) { if (value.isEmpty) { return 0; } return length - (caseSensitive ? replaceAll(value, '') : toLowerCase().replaceAll(value.toLowerCase(), '')).length; }