aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl61
1 files changed, 9 insertions, 52 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 5c93fd4..3fda5df 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -5,17 +5,16 @@
decode_float/1, decode_list/1, decode_option/2, decode_field/2, parse_int/1,
parse_float/1, less_than/2, string_pop_grapheme/1, string_pop_codeunit/1,
string_starts_with/2, wrap_list/1, string_ends_with/2, string_pad/4,
- decode_map/1, uri_parse/1,
- decode_result/1, bit_array_slice/3, decode_bit_array/1, compile_regex/2,
- regex_scan/2, percent_encode/1, percent_decode/1, regex_check/2,
- regex_split/2, base_decode64/1, parse_query/1, bit_array_concat/1,
- bit_array_base64_encode/2, size_of_tuple/1, decode_tuple/1, decode_tuple2/1,
- decode_tuple3/1, decode_tuple4/1, decode_tuple5/1, decode_tuple6/1,
- tuple_get/2, classify_dynamic/1, print/1, println/1, print_error/1,
- println_error/1, inspect/1, float_to_string/1, int_from_base_string/2,
+ decode_map/1, uri_parse/1, decode_result/1, bit_array_slice/3,
+ decode_bit_array/1, percent_encode/1, percent_decode/1, base_decode64/1,
+ parse_query/1, bit_array_concat/1, bit_array_base64_encode/2,
+ size_of_tuple/1, decode_tuple/1, decode_tuple2/1, decode_tuple3/1,
+ decode_tuple4/1, decode_tuple5/1, decode_tuple6/1, tuple_get/2,
+ classify_dynamic/1, print/1, println/1, print_error/1, println_error/1,
+ inspect/1, float_to_string/1, int_from_base_string/2,
utf_codepoint_list_to_string/1, contains_string/2, crop_string/2,
- base16_encode/1, base16_decode/1, string_replace/3, regex_replace/3,
- slice/3, bit_array_to_int_and_size/1, bit_array_pad_to_bytes/1
+ base16_encode/1, base16_decode/1, string_replace/3, slice/3,
+ bit_array_to_int_and_size/1, bit_array_pad_to_bytes/1
]).
%% Taken from OTP's uri_string module
@@ -232,48 +231,6 @@ bit_array_slice(Bin, Pos, Len) ->
catch error:badarg -> {error, nil}
end.
-compile_regex(String, Options) ->
- {options, Caseless, Multiline} = Options,
- OptionsList = [
- unicode,
- ucp,
- Caseless andalso caseless,
- Multiline andalso multiline
- ],
- FilteredOptions = [Option || Option <- OptionsList, Option /= false],
- case re:compile(String, FilteredOptions) of
- {ok, MP} -> {ok, MP};
- {error, {Str, Pos}} ->
- {error, {compile_error, unicode:characters_to_binary(Str), Pos}}
- end.
-
-regex_check(Regex, String) ->
- re:run(String, Regex) /= nomatch.
-
-regex_split(Regex, String) ->
- re:split(String, Regex).
-
-regex_submatches(_, {-1, 0}) -> none;
-regex_submatches(String, {Start, Length}) ->
- BinarySlice = binary:part(String, {Start, Length}),
- case string:is_empty(binary_to_list(BinarySlice)) of
- true -> none;
- false -> {some, BinarySlice}
- end.
-
-regex_matches(String, [{Start, Length} | Submatches]) ->
- Submatches1 = lists:map(fun(X) -> regex_submatches(String, X) end, Submatches),
- {match, binary:part(String, Start, Length), Submatches1}.
-
-regex_scan(Regex, String) ->
- case re:run(String, Regex, [global]) of
- {match, Captured} -> lists:map(fun(X) -> regex_matches(String, X) end, Captured);
- nomatch -> []
- end.
-
-regex_replace(Regex, Subject, Replacement) ->
- re:replace(Subject, Regex, Replacement, [global, {return, binary}]).
-
base_decode64(S) ->
try {ok, base64:decode(S)}
catch error:_ -> {error, nil}