aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-10-27 21:20:27 +0000
committerGitHub <noreply@github.com>2022-10-27 22:20:27 +0100
commit93c3223e8e5d5f9ba2a4020b18bed5802c63bdff (patch)
tree964ffc8fdda2f45088273eb5463dac1782f9582e
parent6c9a956af844379aa8d33fa3832636b33493f776 (diff)
downloadgleam_stdlib-93c3223e8e5d5f9ba2a4020b18bed5802c63bdff.tar.gz
gleam_stdlib-93c3223e8e5d5f9ba2a4020b18bed5802c63bdff.zip
Regex use ucp flag because they use unicode flag (#357)
-rw-r--r--CHANGELOG.md5
-rw-r--r--src/gleam_stdlib.erl1
-rw-r--r--test/gleam/regex_test.gleam6
3 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 215e54b..842c85d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## v0.24.1 - unreleased
+- For `regexp.compile` unicode character properties are now used when
+ resolving `\B`, `\b`, `\D`, `\d`, `\S`, `\s`, `\W`, and `\w` on target
+ Erlang.
- `list.sort` is now tail recursive and will no longer exceed the stack size
on large inputs on target JavaScript.
- `list.sort` is now a "stable" sort, meaning equal elements are sorted in
@@ -11,7 +14,7 @@
- Fixed a bug where `regex.scan` would not work correctly on utf8.
- The performance of `list.flatten` has been greatly improved.
- The `string_builder` module gains the `join` function.
-- The `list` module gains the `shuffle` function.
+- The `list` module gains the `shuffle` function.
## v0.24.0 - 2022-10-15
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 690cc34..961d0af 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -184,6 +184,7 @@ compile_regex(String, Options) ->
{options, Caseless, Multiline} = Options,
OptionsList = [
unicode,
+ ucp,
Caseless andalso caseless,
Multiline andalso multiline
],
diff --git a/test/gleam/regex_test.gleam b/test/gleam/regex_test.gleam
index 30d197f..f2fbd6c 100644
--- a/test/gleam/regex_test.gleam
+++ b/test/gleam/regex_test.gleam
@@ -26,6 +26,12 @@ pub fn compile_test() {
regex.check(re, "abc\n123")
|> should.be_true
+
+ // For Erlang: This test will only passes if unicode and ucp flags are set
+ assert Ok(re) = regex.compile("\\s", options)
+ // Em space == U+2003 == " " == used below
+ regex.check(re, " ")
+ |> should.be_true
}
pub fn check_test() {