diff options
| author | 2023-08-17 17:38:39 +0200 | |
|---|---|---|
| committer | 2023-08-17 17:38:39 +0200 | |
| commit | 6ede6497ad2a63e5ff2b57abba827d0da469f923 (patch) | |
| tree | a183cf6a66ff73b3a524fdc8955036f58ecea454 /xs_regex.h | |
| parent | Return the history in reverse order, which has more sense. (diff) | |
| download | snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.tar.gz snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.tar.xz snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.zip | |
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); | |||
| 8 | #define xs_regex_split(str, rx) xs_regex_split_n(str, rx, XS_ALL) | 8 | #define xs_regex_split(str, rx) xs_regex_split_n(str, rx, XS_ALL) |
| 9 | xs_list *xs_regex_match_n(const char *str, const char *rx, int count); | 9 | xs_list *xs_regex_match_n(const char *str, const char *rx, int count); |
| 10 | #define xs_regex_match(str, rx) xs_regex_match_n(str, rx, XS_ALL) | 10 | #define xs_regex_match(str, rx) xs_regex_match_n(str, rx, XS_ALL) |
| 11 | xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count); | 11 | xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count); |
| 12 | #define xs_regex_replace(str, rx, rep) xs_regex_replace_n(str, rx, rep, XS_ALL) | 12 | #define xs_regex_replace_i(str, rx, rep) xs_regex_replace_in(str, rx, rep, XS_ALL) |
| 13 | #define xs_regex_replace_n(str, rx, rep, count) xs_regex_replace_in(xs_dup(str), rx, rep, count) | ||
| 14 | #define xs_regex_replace(str, rx, rep) xs_regex_replace_in(xs_dup(str), rx, rep, XS_ALL) | ||
| 13 | 15 | ||
| 14 | #ifdef XS_IMPLEMENTATION | 16 | #ifdef XS_IMPLEMENTATION |
| 15 | 17 | ||
| @@ -78,7 +80,7 @@ xs_list *xs_regex_match_n(const char *str, const char *rx, int count) | |||
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | 82 | ||
| 81 | xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count) | 83 | xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count) |
| 82 | /* replaces all matches with the rep string. If it contains unescaped &, | 84 | /* replaces all matches with the rep string. If it contains unescaped &, |
| 83 | they are replaced with the match */ | 85 | they are replaced with the match */ |
| 84 | { | 86 | { |
| @@ -121,6 +123,8 @@ xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, in | |||
| 121 | n++; | 123 | n++; |
| 122 | } | 124 | } |
| 123 | 125 | ||
| 126 | xs_free(str); | ||
| 127 | |||
| 124 | return s; | 128 | return s; |
| 125 | } | 129 | } |
| 126 | 130 | ||