Added new replace function

pull/41/head
parent 7e1decdcd1
commit 8e3dde8c9e

@ -662,6 +662,26 @@ char *yon_char_replace(char *source, char *find, char*replace){
return source;
}
char *yon_char_replace_single(char *source, char *find, char *replace){
if (!yon_char_is_empty(source)&&!yon_char_is_empty(find)){
char *current = NULL;
if ((current=strstr(source,find))){
int size = sizeof(char)*(strlen(source)-strlen(find)+strlen(replace)+1);
int replace_pos = strlen(source)-strlen(find);
char *final = malloc(size);
memset(final,0,size);
memcpy(final,source,replace_pos);
memcpy(final+replace_pos,replace,strlen(replace));
if (strlen(source+replace_pos)>strlen(find)){
memcpy(final+strlen(final),source+strlen(find),strlen(source+strlen(find)));
}
return final;
}
}
return NULL;
}
char **yon_char_parse(char *parameters, int *size, char *divider){
*size=0;
if (parameters){

@ -417,6 +417,7 @@ char *yon_char_from_long(long int_to_convert);
* Заменяет в строке [source] все вхождения строки [find] на [replace]
*/
char *yon_char_replace(char *source, char *find, char*replace);
char *yon_char_replace_single(char *source, char *find, char *replace);
/**yon_char_parse(char *parameters, int *size, char *divider)
* [EN]

Loading…
Cancel
Save