Page 1 of 1

Possible bug when backreferencing a capturing group

Posted: Mon Jul 27, 2015 3:24 pm
by Quuq
Hey dudes,

I ran into some unusual behavior today. I'm using a backreferenced capturing group to make sure that a trigger only fires when someone announces their own name in a message. Here's the string I intended to use:

Code: Select all

^(\w+) tells (?:the )?\w+(?::\d)?, '\1 is tanking
That wasn't firing. :cry: However, if I shortened it to

Code: Select all

^(\w+) tells (?:the )?\w+(?::\d)?, '\1 is ta
things worked fine.

Is there some hard limit set on the number of characters that can be parsed after a backreference or have I stumbled onto a possible bug?

Re: Possible bug when backreferencing a capturing group

Posted: Mon Jul 27, 2015 7:20 pm
by Gimagukk
This is a bug; I'm working on some performance enhancements to regex searches which will correct this when I release them, but for now you putting a pair of parenthesis after the back-reference should work around the issue:

Code: Select all

^(\w+) tells (?:the )?\w+(?::\d)?, '\1() is tanking

Re: Possible bug when backreferencing a capturing group

Posted: Mon Jul 27, 2015 8:58 pm
by Quuq
Thanks for the super easy workaround, Gima. I'm looking forward to the lean, mean, regex-parsing (state) machine!