Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Jan 4, 2024
1 parent 572491e commit 9cd232f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/regex/exptransformation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ func expandArbitrayBytes(exp: Exp, flags: RegexFlags): Exp =
var node2 = node
node2.cp = Rune((node.cp.uint32 and (0xff'u32 shl (i * 8))) shr (i * 8))
result.s.add node2
result.s = newSeqOfCap[Node](exp.s.len)
result.s = newSeq[Node](exp.s.len)
result.s.setLen 0
for node in exp.s:
if node.kind notin {reChar, reCharCi}:
result.s.add node
Expand Down
17 changes: 17 additions & 0 deletions tests/tests2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3119,3 +3119,20 @@ when not defined(js) or NimMajor >= 2:
check replace("\xF0\xAF\xA2\x94\x94", re2(r"弢{2}", flags), "abc") == "abc"
check replace("\xF0\xAF\xA2\x94\x94", re2(r"弢+", flags), "abc") == "abc"
check replace("\x02\xF8\x95\x02\xF8\x95", re2(r"\x{2F895}{2}", flags), "abc") == "abc"
check match("\xF0\xAF\xA2\x94", re2(r".{4}", flags))
check match("\x02\xF8\x95", re2(r".+(?<=\x{2F895})", flags))
check(not match("\x02\xF8\x95\x95", re2(r".+(?<=\x{2F895})", flags)))
check match("\x02\xF8\x95\x02\xF8\x95", re2(r".+(?<=\x{2F895}+)", flags))
check match("\x02\xF8\x95\x02\xF8\x95", re2(r".+(?<=\x{2F895}{2})", flags))
check match("弢", re2(r".+(?<=弢)", flags))
check match("\xF0\xAF\xA2\x94", re2(r".+(?<=弢)", flags))
check match("弢", re2(r".+(?<=\xF0\xAF\xA2\x94)", flags))
check match("\xF0\xAF\xA2\x94", re2(r".+(?<=弢)", flags))
check match("\xF0\xAF\xA2\x94", re2(r".{4}(?<=弢)", flags))
check match("\xF0\xAF\xA2\x94", re2(r".{4}(?<=.{4})", flags))
block:
var m: RegexMatch2
check match("a", re2(r"a", flags)) and
m.groupsCount == 0
check match("\x02\xF8\x95", re2(r"\x{2F895}", flags)) and
m.groupsCount == 0

0 comments on commit 9cd232f

Please sign in to comment.