mIRC Homepage
Posted By: keyeslol Regex ignore trailing space - 01/01/16 06:37 AM
Testing some regex out, and can't seem to get my pattern match to ignore the space between capture groups.

Pattern i am using: ((.{2,}?)\2{4,})

if i enter: "the quick brown fox jumps over? " and put it in 5 times, and the 6th message does not contain a trailing space, it seems to not match the pattern.

Thanks!
Posted By: Loki12583 Re: Regex ignore trailing space - 01/01/16 02:04 PM
I think this is what you want:

((.{2,}?)(\s*\2){4,})

And it's nearly identical to what you wanted here: https://forums.mirc.com/ubbthreads.php/topics/255708/
Posted By: keyeslol Re: Regex ignore trailing space - 01/01/16 04:40 PM
That's where i made the mistake, i didn't put parenthesis near the \2.

There is a slight problem, where putting these parenthesis in cause a 3rd capture group to be evaluated. Getting some weird behavior now.

I moved it and it seems to be working in the debugger, but still capturing a 3rd group, which is a single white space by itself.
Code:
((.{2,}?(\s))\2{3,})
Posted By: Wims Re: Regex ignore trailing space - 01/01/16 06:08 PM
You can use (?:regex) for a non capturing group.
Posted By: keyeslol Re: Regex ignore trailing space - 01/01/16 06:23 PM
Thanks wims! Now when looking at a regex builder, it appears to be capturing correctly, however my do action is not working.

Code:
if ($regex($1-,/(.{2,}?)(?:\s*\1){3,}/i)) {
  do
}
Posted By: Wims Re: Regex ignore trailing space - 01/01/16 07:37 PM
Yes, as Loki12583 said in that link, the comma seperate arguments here, put the whole pattern in a local %variable.
Posted By: keyeslol Re: Regex ignore trailing space - 01/01/16 08:33 PM
Thanks guys!
© mIRC Discussion Forums