mIRC Home    About    Download    Register    News    Help

Print Thread
Regex ignore trailing space #256253 01/01/16 06:37 AM
Joined: May 2015
Posts: 133
K
keyeslol Offline OP
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
Re: Regex ignore trailing space [Re: keyeslol] #256256 01/01/16 02:04 PM
Joined: Jan 2004
Posts: 1,306
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,306
I think this is what you want:

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

And it's nearly identical to what you wanted here: http://forums.mirc.com/ubbthreads.php/topics/255708/

Re: Regex ignore trailing space [Re: Loki12583] #256257 01/01/16 04:40 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline OP
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
Re: Regex ignore trailing space [Re: keyeslol] #256258 01/01/16 06:08 PM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
You can use (?:regex) for a non capturing group.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Regex ignore trailing space [Re: Wims] #256259 01/01/16 06:23 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline OP
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
Re: Regex ignore trailing space [Re: keyeslol] #256260 01/01/16 07:37 PM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
Yes, as Loki12583 said in that link, the comma seperate arguments here, put the whole pattern in a local %variable.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Regex ignore trailing space [Re: Wims] #256261 01/01/16 08:33 PM
Joined: May 2015
Posts: 133
K
keyeslol Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Thanks guys!


twitter @keyeslol