Skip to content

Commit 93c3223

Browse files
authored
Regex use ucp flag because they use unicode flag (#357)
1 parent 6c9a956 commit 93c3223

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## v0.24.1 - unreleased
44

5+
- For `regexp.compile` unicode character properties are now used when
6+
resolving `\B`, `\b`, `\D`, `\d`, `\S`, `\s`, `\W`, and `\w` on target
7+
Erlang.
58
- `list.sort` is now tail recursive and will no longer exceed the stack size
69
on large inputs on target JavaScript.
710
- `list.sort` is now a "stable" sort, meaning equal elements are sorted in
@@ -11,7 +14,7 @@
1114
- Fixed a bug where `regex.scan` would not work correctly on utf8.
1215
- The performance of `list.flatten` has been greatly improved.
1316
- The `string_builder` module gains the `join` function.
14-
- The `list` module gains the `shuffle` function.
17+
- The `list` module gains the `shuffle` function.
1518

1619
## v0.24.0 - 2022-10-15
1720

src/gleam_stdlib.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ compile_regex(String, Options) ->
184184
{options, Caseless, Multiline} = Options,
185185
OptionsList = [
186186
unicode,
187+
ucp,
187188
Caseless andalso caseless,
188189
Multiline andalso multiline
189190
],

test/gleam/regex_test.gleam

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ pub fn compile_test() {
2626

2727
regex.check(re, "abc\n123")
2828
|> should.be_true
29+
30+
// For Erlang: This test will only passes if unicode and ucp flags are set
31+
assert Ok(re) = regex.compile("\\s", options)
32+
// Em space == U+2003 == " " == used below
33+
regex.check(re, " ")
34+
|> should.be_true
2935
}
3036

3137
pub fn check_test() {

0 commit comments

Comments
 (0)