var strlunga = "tutto quello che vuoi trovare qui dentro";

var out = strlunga.match(/tr/g); // ricerca di tutte le sringhe "tr"
var num = out.length;
alert("ho trovato "+num+" occorrenze nella stringa");