-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Hello,
When I try to use a regex with an index submatch, the index submatch has an "off by two" behavior.
I would expect this to work:
However, autolink is adding extra parenthesis around the regex, so instead I have to do this:
(Note the ${3})
This can be reproduced using this sequence of commands:
/autolink add submatch
/autolink set submatch Pattern prefix/(.*)
/autolink set submatch Template final/${1}
/autolink test submatch prefix/hello
/autolink set submatch Template final/${3}
/autolink test submatch prefix/hello
I acknowledge I can use named submatch groups but the golang regex dialect isn't portable to the other languages we are using (ruby) so I'd like to use the numeric submatches instead.
Workarounds
- Ruby doesn't support
(?P<name>submatch)syntax for subgroups, butgrep -Pdoes - We can use the off-by-2 index, but it's unintuitive when writing the code and prone to error
This isn't a blocker for me, but figured I'd drop this here. At the very least, maybe we update the README so it calls out this unexpected behavior?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels