If you want to count the number of occurrences of one string inside another, which approach is better in terms of simplicity and/or performance? -
- using indexOfin afor/whileloop
- using a regular expression
And if it is the latter, then what is the best way to do it?
 
    