From 7df5713322f85c2726bdc9167b0f4d3a4846fcdd Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 26 Oct 2021 08:08:45 -0500 Subject: [PATCH] added string.replace --- core/string.onyx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/string.onyx b/core/string.onyx index aa639618..9b6da85d 100644 --- a/core/string.onyx +++ b/core/string.onyx @@ -261,6 +261,12 @@ advance :: #match { } } +replace :: (s: str, to_replace: u8, replace_with: u8) { + for ^c: str { + if *c == to_replace do *c = replace_with; + } +} + read_until :: (s: ^str, upto: u8, skip := 0) -> str { if s.count == 0 do return ""; -- 2.25.1