From ed9405a0eb12061b3ce680f80e6d89b5ff518f21 Mon Sep 17 00:00:00 2001 From: inoas Date: Tue, 25 Oct 2022 23:01:23 +0200 Subject: fix regex.scan to work correclty with utf8 strings --- test/gleam/regex_test.gleam | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/gleam/regex_test.gleam b/test/gleam/regex_test.gleam index cdd6e68..30d197f 100644 --- a/test/gleam/regex_test.gleam +++ b/test/gleam/regex_test.gleam @@ -64,4 +64,18 @@ pub fn scan_test() { Match(content: "on a boat", submatches: [None, Some("boat")]), Match(content: "in a lake", submatches: [None, Some("lake")]), ]) + + assert Ok(re) = regex.from_string("answer (\\d+)") + regex.scan(re, "Is the answer 42?") + |> should.equal([Match(content: "answer 42", submatches: [Some("42")])]) + + assert Ok(re) = regex.from_string("(\\d+)") + regex.scan(re, "hello 42") + |> should.equal([Match(content: "42", submatches: [Some("42")])]) + + regex.scan(re, "你好 42") + |> should.equal([Match(content: "42", submatches: [Some("42")])]) + + regex.scan(re, "你好 42 世界") + |> should.equal([Match(content: "42", submatches: [Some("42")])]) } -- cgit v1.2.3