mIRC Home    About    Download    Register    News    Help

Print Thread
#137393 12/12/05 08:09 AM
Joined: Mar 2005
Posts: 39
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Mar 2005
Posts: 39
Hello, i was wondering if there's an shorter code to check for 4 or more repeating characters?

This way works, but its very long if u gonna use the whole alphabet..

Code:
if ($count($1-,aaaa,bbbb,pppp,etc)

#137394 12/12/05 08:16 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
var %a = a b c d e f g h i j k l m n o p q r s t u v w x y z
while %a {
if $str($gettok(%a,1,32),4) isin $1- {
echo -a $gettok(%a,1,32)
}
var %a = $remtok(%a,$gettok(%a,1,32),1,32)
}
  

Not knowing exactly why you're searching for 4 character repeats, the above code might work...might not be shorter than how you were doing it, but ....

#137395 12/12/05 10:42 AM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
if($regex(aaaabbbb,/(\w{4})/g)) { do something }

$v1 will hold how many repetitions there have been found, so in this example 2, with $regml(N) you can get the Nth repition in order of apearance so in this case
$regml(1) is aaaa
$regml(2) is bbbb





might not be exactly what you want as this returns true for
letter, number or an underscore being repeated 4 times

in case you only want letters use
if($regex(aaaabbbb,/([a-z]{4})/gi)) { do something }

Last edited by Mpdreamz; 12/12/05 10:50 AM.

$maybe
#137396 12/12/05 12:57 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This won't work. \w{4} matches ANY 4 <letter/number/_> characters, not the same ones. You'd need

var %r = /(\w)\1{3,}/g | if ($regex($1-,%r)) { do stuff }

in both cases, $regml(N) returns the Nth repeating letter (it can be modified to catch the actual string of repeating letters too)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#137397 13/12/05 01:00 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
doh ! cant believe i missed that :tongue:


$maybe

Link Copied to Clipboard