The following script
might work, since I'm writing it here and now without testing:
NPC Code:
if (created) {
setstring string,abbaaaabaab;
setstring partstring,b;
this.partcount=0;
this.indexof=0;
while (this.indexof!=-1) {
this.indexof=indexof(#s(partstring),#e(this.indexo f,-1,#s(string));
this.partcount+=(this.indexof!=-1);
}
message #s(partstring) occurs #v(this.partscount) times in #s(string);
}
If it does work it should display the following message: "b occurs 4 times in abbaaaabaab"