I'm currently using a counter to find occurrences of a substring within a string, but it's case sensitive. Here's my current code:
count = (string.match(new RegExp(substring, 'gm')) || []).length;
For instance, if the substring appears in the string with a different case, the count will be '0'.
Is there a way to implement a case-insensitive counter instead?