aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorRado <r.hampartsumyan@viscomp.bg>2024-06-18 21:27:46 +0300
committerLouis Pilfold <louis@lpil.uk>2024-06-23 13:37:27 +0100
commit53b475e86fc3bd5d31773de3bf395b6c91b79a6c (patch)
tree26fa73e0db558ee94a2ef9dc374cd9b134664090 /src/gleam_stdlib.erl
parente5c3a0d8cf2d631c4e74dc02b14f5d82b3ed15af (diff)
downloadgleam_stdlib-53b475e86fc3bd5d31773de3bf395b6c91b79a6c.tar.gz
gleam_stdlib-53b475e86fc3bd5d31773de3bf395b6c91b79a6c.zip
Implement regex.replace
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 2596f41..97b8831 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -14,7 +14,7 @@
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_decode/1, string_replace/3
+ crop_string/2, base16_decode/1, string_replace/3, regex_replace/3
]).
%% Taken from OTP's uri_string module
@@ -259,6 +259,9 @@ regex_scan(Regex, String) ->
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}