This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Pattern for a Regexp

Old posts that have not been replied to for several years.
Locked
C
Caribou
Voice
Posts: 28
Joined: Thu Apr 15, 2004 12:51 pm
Location: France

Pattern for a Regexp

Post by Caribou »

Hi there,

Im trying to make a pattern to detect a specific mirccolor and report it.

i want him to find Yellow on Darkblue

here is what i made actually :

"()(8|08|24|40|56|72|88)(,)(02|2|18|34|50|66|82|98)"

But with this i got a problem, sometimes color can be "24,23" and it will detect it as "24,2", so i want him to check if there are no numeric character just next

I tried to add something like "[a-zA-Z]" but it wasn't working, im from mirc scripting and sometimes i make few mistake, this is working on mircscripting.

Is there anyway to add just at the end of my actual patern a sequence who mean 'anything else than a number' ?

Thanks for any help or alternate solutions :)
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

(0)?8,(0)?2 or \003(0)?8,(0)?2 should match the color scheme you are looking for. note the 0's are optional because they are not required in irc therefor not always used. You shouldn't need the higher number because nobody ever really uses them. but modified version would be something like..

Code: Select all

(0)?(8|24|40|56|72|88),(0)?(2|18|34|50|66|82|98)
Also, the ()'s are not needed around a single charactor, they are use for mainly for optional items, or to group a list of several possibilities.

Oh, and something like [^\d] would detect anything not a number
C
Caribou
Voice
Posts: 28
Joined: Thu Apr 15, 2004 12:51 pm
Location: France

Post by Caribou »

im not able to use [^\d], maybe i made something wrong with it.
[regexp "(8|08|24|40|56|72|88),(2|02|18|34|50|66|82|98)[^\d]" $text]
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

try \D+ instead of [^\d]
\D is essentially the same thing as ^\d... You may also want to look at exactly what is being passed, maybe there is other control codes, or a space or something else between the color codes and the non-digit.

Such as '(K)08,02(B)text' or '(K)08,02 text'
C
Caribou
Voice
Posts: 28
Joined: Thu Apr 15, 2004 12:51 pm
Location: France

Post by Caribou »

No, im sorry you were right, [^\d] is working correctly, i just add problem cause my bot tried to launch this as a command [], i don't know why but i made this :

Code: Select all

if {[regexp "(8|08|24|40|56|72|88),(2\[^\\d]|02|18|34|50|66|82|98)" $arg] && [regexp "" $arg]} {
detect
} elseif {[regexp "(8\[^\\d]|08|24|40|56|72|88)" $arg] && [regexp ",(2\[^\\d]|02|18|34|50|66|82|98)" $arg] && [regexp "" $arg]} {
detect
}
And i think it would detect any sort of bold-yellow/darkblue, it seems to working nice, what do you think of this ?

Thanks a lot for your help :mrgreen:
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

Don't know if this makes much difference, but i always put regular expressions inside {} brackets rather than "". As i know {} forces it to ignore any special charactors that tcl would normally parse itself. (such as the []'s)

This should eliminate the need for the extra \ escapes you put into the code.
Locked