|
Joined: Mar 2005
Posts: 14
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 14 |
Is there a way that i can detect a range of chars with on text?
For instains. When someone only uses 012 in there message and nothing else. like '120001220200102002', that i can detect it and akt on that? Something like [0..2] to detect it.. And mabye also [0..2-a..b]????
Thx in advance.
GreetZ BlackDex To boldly go where no one has gone before.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:text:*:#:{
set %entry $remove($2-,0,1,2,a,b)
if !%entry { <actions if entry contained only 0's, 1's, 2's, a's and/or b's>
}
}
I think this might be better done using regex, but I'm not familiar enough with regex to give you a code using it, however, the above should work
|
|
|
|
Joined: Mar 2005
Posts: 14
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 14 |
Thx... that works  .
GreetZ BlackDex To boldly go where no one has gone before.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Might want to strip the text (might not as well for all i know) Also I dont understand why you selected to start from $2 ?
[code] on *:text:*:#:{ set %entry $remove($strip($1-),0,1,2,a,b) if !%entry { <actions if entry contained only 0's, 1's, 2's, a's and/or b's> } } [code]
* Maybe change to set %entry $remove($strip($1-),0,1,2,a,b,$chr(32)) to catch spaces if they dont count as other characters, since "0 1 2 a b" well produce a 4 bytes string of 4 spaces in a row, so it looks blank but isnt.
|
|
|
|
Joined: Mar 2005
Posts: 14
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 14 |
i indeed changed it to $1 forgot to mention that... I need to check if it is HEX or BINARY only. For a script im writing atm.
GreetZ BlackDex To boldly go where no one has gone before.
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
on $*:TEXT:/^[01 ]+$/S:#: would react to binary only (and spaces) in a channel. on $*:TEXT:/^[0-9A-F ]+$/iS:#: would react to hex only (and spaces) in a channel.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
 I was right...a regular expression would've been shorter, and therefore better, as the amount of computing time is less. Glad mine worked...I think the reason I used $2, rather than $1 is because I was rushing to get a response posted while on my coffee break.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Regex really are the way to go (I however have to look up all the symbols becuase i never remebr what they mean)
i did a comparision test using a 1000 reps of
while (%i) { if (!$remove($$1-,0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,%s)) { } | dec %i } %s = $chr(32) while (%i) { if ($regex($$1-,/^[0-9A-F ]+$/iS)) { } | dec %i }
the results were around 1.650 ticks for remove and regex was 0.195 thats like 8 to 9 times faster
|
|
|
|
Joined: Dec 2004
Posts: 13
Pikka bird
|
Pikka bird
Joined: Dec 2004
Posts: 13 |
regex and dll which one is the fastest
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
there two different things you cant compare them.
|
|
|
|
|