-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
29 lines (26 loc) · 1.39 KB
/
ft_strtrim.c
File metadata and controls
29 lines (26 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
███▄ ▄███▓▓█████ ███▄ █ ▄▄▄ ██████▓██ ██▓
▓██▒▀█▀ ██▒▓█ ▀ ██ ▀█ █ ▒████▄ ▒██ ▒ ▒██ ██▒
▓██ ▓██░▒███ ▓██ ▀█ ██▒▒██ ▀█▄ ░ ▓██▄ ▒██ ██░
▒██ ▒██ ▒▓█ ▄ ▓██▒ ▐▌██▒░██▄▄▄▄██ ▒ ██▒ ░ ▐██▓░
▒██▒ ░██▒░▒████▒▒██░ ▓██░ ▓█ ▓██▒▒██████▒▒ ░ ██▒▓░
░ ▒░ ░ ░░░ ▒░ ░░ ▒░ ▒ ▒ ▒▒ ▓▒█░▒ ▒▓▒ ▒ ░ ██▒▒▒
░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ▒▒ ░░ ░▒ ░ ░▓██ ░▒░
░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ▒ ░░
░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░*/
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int i;
int lens1;
lens1 = ft_strlen(s1) -1;
i = 0;
if (!s1 || !set)
return (NULL);
while (s1[i] && ft_strchr(set, s1[i]))
i++;
while (lens1 > i && ft_strchr(set, s1[lens1]))
lens1--;
return (ft_substr(s1, i, lens1 - i +1));
}