Last active
December 17, 2015 08:59
Revisions
-
brbsh revised this gist
Jun 25, 2013 . 1 changed file with 50 additions and 61 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,33 +20,29 @@ bool:repeating (true/false) - если true, вырежет все найден stock strsubdel(string[], const sub[], bool:sensetive = true, bool:repeating = true) { if((string[0] <= '\1') || (sub[0] <= '\1')) return -1; new sublen = strlen(sub); new found; if(repeating) { new rt; while((found = strfind(string, sub, !sensetive)) != -1) { strdel(string, found, (found + sublen)); rt++; } return rt; } if((found = strfind(string, sub, !sensetive)) == -1) return -1; strdel(string, found, (found + sublen)); return 1; } @@ -73,44 +69,37 @@ bool:repeating (true/false) - если true, вырежет все найден stock strsubdel_ex(string[], bool:sensetive, bool:repeating, ...) { new args; if((string[0] <= '\1') || ((args = numargs()) == 3)) return -1; for(new current = 3, arg[256], i; current != args; current++) { while((arg[i] = getarg(current, i)) { i++; } arg[i] = 0; if((args = strfind(string, arg, !sensetive)) == -1) continue; if(!repeating) { strdel(string, args, (args + strlen(arg))); rt++; continue; } else { while((args = strfind(string, arg, !sensetive)) != -1) { strdel(string, args, (args + strlen(arg))); rt++; } } } return rt; } -
brbsh created this gist
May 15, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,116 @@ /* Функция для вырезания подстроки из строки назначения strsubdel(string[], const sub[], bool:sensetive = true, bool:repeating = true) Аргументы: string[] - строка обработки (назначения) sub[] - подстрока, или то что нужно вырезать bool:sensetive (true/false) - если true, функция будет чувствительна к регистру, иначе - нет bool:repeating (true/false) - если true, вырежет все найденные подстроки, иначе - первую попавшуюся Возвращает: -1 - Возникла ошибка (строка пуста/введена пустая подстрока) Иначе вернет количество вырезанных подстрок */ stock strsubdel(string[], const sub[], bool:sensetive = true, bool:repeating = true) { if(!string[0] || string[0] == '\1' || !sub[0] || sub[0] == '\1') return -1; new sublen = strlen(sub), found ; if(repeating) { new rt ; while((found = strfind(string,sub,!sensetive)) != -1) { strdel(string,found,(found + sublen)); rt++; } return rt; } if((found = strfind(string,sub,!sensetive)) == -1) return -1; strdel(string,found,(found + sublen)); return 1; } /* Функция для вырезания подстрок из строки назначения strsubdel_ex(string[], bool:sensetive, bool:repeating, ...) Аргументы: string[] - строка обработки (назначения) bool:sensetive (true/false) - если true, функция будет чувствительна к регистру, иначе - нет bool:repeating (true/false) - если true, вырежет все найденные подстроки, иначе - первую попавшуюся ... - подстроки, которые нужно вырезать Возвращает: -1 - Возникла ошибка (строка пуста/введена пустая подстрока/превышено количество аргументов) Иначе вернет количество вырезанных подстрок */ stock strsubdel_ex(string[], bool:sensetive, bool:repeating, ...) { new args ; if(!string[0] || string[0] == '\1' || (args = numargs()) > 16) return -1; new args_var[16][128], current = -1, rt ; for( ; args != 2; args--) { while((args_var[(args - 3)][++current] = getarg(args,current))) { } } for(current = 0; current != 16; current++) { if((args = strfind(string,args_var[current],!sensetive)) == -1) continue; if(!repeating) { strdel(string,args,(args + strlen(args_var[current]))); rt++; continue; } else { while((args = strfind(string,args_var[current],!sensetive)) != -1) { strdel(string,args,(args + strlen(args_var[current]))); rt++; } } } return rt; }