Possible bug when backreferencing a capturing group

Post Reply
Quuq
Posts: 3
Joined: Mon Jul 27, 2015 3:17 pm

Possible bug when backreferencing a capturing group

Post by Quuq » Mon Jul 27, 2015 3:24 pm

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?

Gimagukk
Site Admin
Posts: 237
Joined: Wed Oct 26, 2011 9:29 pm

Re: Possible bug when backreferencing a capturing group

Post by Gimagukk » Mon Jul 27, 2015 7:20 pm

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

Quuq
Posts: 3
Joined: Mon Jul 27, 2015 3:17 pm

Re: Possible bug when backreferencing a capturing group

Post by Quuq » Mon Jul 27, 2015 8:58 pm

Thanks for the super easy workaround, Gima. I'm looking forward to the lean, mean, regex-parsing (state) machine!

Post Reply