JaTochNietDan

str_replace function for PAWN

May 9th, 2012
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.41 KB | None | 0 0
  1. stock str_replace(const needle[], const replace[], haystack[], bool:ignorecase = true, needlen = sizeof(needle), haylen = sizeof(haystack))
  2. {
  3.     new
  4.         count,
  5.         index = strfind(haystack, needle, ignorecase);
  6.    
  7.     while(index != -1)
  8.     {
  9.         strdel(haystack, index, index + (needlen - 1));
  10.         strins(haystack, replace, index, haylen);
  11.        
  12.         index = strfind(haystack, needle, ignorecase);
  13.         count++;
  14.     }
  15.     return count;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment