-----Oorspronkelijk bericht-----
Van: Pascal Peters
Verzonden: vr 17/10/2003 15:08
Aan: CF-Talk
CC:
Onderwerp: RE: number of occurrences in a string.
The function doesn't look correct. This should work (I modified it, but didn't test)
function WordInstance(word,string){
var i = 0;
var start = 1;
var exit = false;
var tmp = "";
var special_char_list = "\,+,*,?,.,[,],^,$,(,),{,},|,-";
var esc_special_char_list = "\\,\+,\*,\?,\.,\[,\],\^,\$,\(,\),\{,\},\|,\-";
word = ReplaceList(word, special_char_list, esc_special_char_list);
string = " " & string & " ";
while(NOT exit){
tmp=REFindNoCase("[^a-z]+#word#[^a-z]+",string,start,true);
if(tmp.pos[0] gt 0){
i=i+1;
start=tmp.pos[0]+tmp.len[0];
}else{
exit = true;
}
}
return i;
}
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

