mIRC Home    About    Download    Register    News    Help

Print Thread
#256253 01/01/16 06:37 AM
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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!


twitter @keyeslol
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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/

Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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,})

Last edited by keyeslol; 01/01/16 05:28 PM.

twitter @keyeslol
Joined: Jul 2006
Posts: 4,134
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,134
You can use (?:regex) for a non capturing group.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
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
}

Last edited by keyeslol; 01/01/16 06:26 PM.

twitter @keyeslol
Joined: Jul 2006
Posts: 4,134
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,134
Yes, as Loki12583 said in that link, the comma seperate arguments here, put the whole pattern in a local %variable.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Thanks guys!


twitter @keyeslol

Link Copied to Clipboard