Skip to content

Commit

Permalink
fix #97: wrap references in a non-capturing group
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloso committed Oct 27, 2023
1 parent d21cf6b commit acda169
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pomsky-lib/src/exprs/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl RegexReference {
match self {
&RegexReference::Number(number) => {
debug_assert!(number <= 99);
write!(buf, "\\{number}").unwrap();
write!(buf, "(?:\\{number})").unwrap();
}
RegexReference::Name(name) => {
write!(buf, "\\k<{name}>").unwrap();
Expand Down
4 changes: 4 additions & 0 deletions pomsky-lib/tests/testcases/references/one.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! flavor=Pcre
:('test') ::1
-----
(test)(?:\1)
4 changes: 4 additions & 0 deletions pomsky-lib/tests/testcases/references/one_named.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! flavor=Pcre
:foo('foo') ::1 ::foo
-----
(?P<foo>foo)(?:\1)(?:\1)

0 comments on commit acda169

Please sign in to comment.