diff options
author | default <nobody@localhost> | 2023-08-17 17:38:39 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-08-17 17:38:39 +0200 |
commit | 6ede6497ad2a63e5ff2b57abba827d0da469f923 (patch) | |
tree | a183cf6a66ff73b3a524fdc8955036f58ecea454 /xs_regex.h | |
parent | b3b4a4ef61da620d97e1373b16b9844fa6777370 (diff) |
Convert 'Link' attachments that have a media extension to something more useful.
Diffstat (limited to 'xs_regex.h')
-rw-r--r-- | xs_regex.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -8,8 +8,10 @@ xs_list *xs_regex_split_n(const char *str, const char *rx, int count); #define xs_regex_split(str, rx) xs_regex_split_n(str, rx, XS_ALL) xs_list *xs_regex_match_n(const char *str, const char *rx, int count); #define xs_regex_match(str, rx) xs_regex_match_n(str, rx, XS_ALL) -xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count); -#define xs_regex_replace(str, rx, rep) xs_regex_replace_n(str, rx, rep, XS_ALL) +xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count); +#define xs_regex_replace_i(str, rx, rep) xs_regex_replace_in(str, rx, rep, XS_ALL) +#define xs_regex_replace_n(str, rx, rep, count) xs_regex_replace_in(xs_dup(str), rx, rep, count) +#define xs_regex_replace(str, rx, rep) xs_regex_replace_in(xs_dup(str), rx, rep, XS_ALL) #ifdef XS_IMPLEMENTATION @@ -78,7 +80,7 @@ xs_list *xs_regex_match_n(const char *str, const char *rx, int count) } -xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count) +xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count) /* replaces all matches with the rep string. If it contains unescaped &, they are replaced with the match */ { @@ -121,6 +123,8 @@ xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, in n++; } + xs_free(str); + return s; } |