31 lines
1.2 KiB
C
31 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strtrim.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mdenys <mdenys@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/11/02 17:58:31 by mdenys #+# #+# */
|
|
/* Updated: 2020/11/03 11:18:41 by mdenys ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strtrim(char const *s1, char const *set)
|
|
{
|
|
char *new;
|
|
int len;
|
|
|
|
len = 0;
|
|
if (!s1 || !set)
|
|
return (NULL);
|
|
while (*s1 && ft_strchr(set, *s1))
|
|
s1++;
|
|
len = ft_strlen((char*)s1);
|
|
while (len && ft_strchr(set, s1[len]))
|
|
len--;
|
|
new = ft_substr((char *)(s1), 0, len + 1);
|
|
return (new);
|
|
}
|