I was doing _javascript_ when I posted this. Obviously the first element in the array has index 1 in CF. So replace [0] by [1] in my code.

-----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]

Reply via email to