mIRC Home    About    Download    Register    News    Help

Print Thread
on text and [A..Z-0..1] detection? #115906 31/03/05 12:05 PM
Joined: Mar 2005
Posts: 14
B
BlackDex Offline OP
Pikka bird
OP Offline
Pikka bird
B
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.
Re: on text and [A..Z-0..1] detection? #115907 31/03/05 02:34 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
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

Re: on text and [A..Z-0..1] detection? #115908 31/03/05 03:45 PM
Joined: Mar 2005
Posts: 14
B
BlackDex Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2005
Posts: 14
Thx... that works smile.


GreetZ BlackDex
To boldly go where no one has gone before.
Re: on text and [A..Z-0..1] detection? #115909 31/03/05 04:27 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
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.

Re: on text and [A..Z-0..1] detection? #115910 31/03/05 04:32 PM
Joined: Mar 2005
Posts: 14
B
BlackDex Offline OP
Pikka bird
OP Offline
Pikka bird
B
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.
Re: on text and [A..Z-0..1] detection? #115911 01/04/05 12:02 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
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
Re: on text and [A..Z-0..1] detection? #115912 01/04/05 01:57 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
grin 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.

Re: on text and [A..Z-0..1] detection? #115913 01/04/05 06:30 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
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

Re: on text and [A..Z-0..1] detection? #115914 02/04/05 07:27 AM
Joined: Dec 2004
Posts: 13
S
ScottK Offline
Pikka bird
Offline
Pikka bird
S
Joined: Dec 2004
Posts: 13
regex and dll which one is the fastest

Re: on text and [A..Z-0..1] detection? #115915 02/04/05 07:46 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
there two different things you cant compare them.