mIRC Home    About    Download    Register    News    Help

Print Thread
#231346 13/04/11 07:01 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Hello, I am trying to make a popular trivia game work on a new network. The issue is the script looks for the first character of incoming text using regex, but the new network has font code for $1. I haven't learned regex in depth yet, can anyone please help me with the regex matches?

The script has 3 text events. It is pretty complicated so I don't want to take the time to combine them into one text event, though that would be much easier for these matches.

I need to match the first character of the text following the font code.


Code:
This is how the text with the font code looks.
##*#Arial Black~#7F7F7F~1~1#*##This is a sentence.

This is the regex I was given to strip the font code normally.
/tokenize 32 $regsubex($1-,/^##\*.*\*##/,$null)

These are regex matches I was given by friends but they allow all text.

The first text event is supposed to check for text that starts with a . only.

on $*:text:/^(##\*.*\*##)?(.*)/:#:{ }


The second text event is supposed to check for text starting with ! only.

on $*:text:%st_filter_cmd:#:{ }

%st_filter_cmd = /^(##\*.*\*##)?(!*)/gS


The last text event checks for all text that doesn't start with a . or a !.

on $*:text:%st_filter_norm:#:{ }

%st_filter_norm = /(?!\.|\^|!)##\*.*\*##/gS


Can anyone please help me with the proper regex to do these things? Thank you.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
You can make thing simple with $regsubex and the first pattern you gave (I changed it a bit) :
Code:
on *:text:*:#:{
tokenize 32 $regsubex($1-,/^##\*#.*?#\*##/S,)
if ($left($1,1) == .) { dot part }
elseif ($v1 == !) { ! part }
else { others part }
}
A dot match any caracter so you cannot use a litteral dot in the pattern to match a dot, you have to escape it (for example), with a \ : \.

Last edited by Wims; 13/04/11 07:24 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Originally Posted By: DJ_Sol
Hello, I am trying to make a popular trivia game work on a new network.
The script has 3 text events. It is pretty complicated so I don't want to take the time to combine them into one text event, though that would be much easier for these matches.


Thank you for your suggestion but I need to keep the 3 separate text events the way they are. I just need to strip the font code in each match.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
You don't 'need' to do that, you do 'want', because you could simply take your 3 big event, put them in 3 alias, and call them as I showed, it should work just the same.
Anyways, if you want to keep your 3 events, just use the tokenize + $regsubex on top of each event, and use $1- as if there were no extra things in front of each message smile

Here is something you can do if you want to keep the matching part inside the event definition :
Code:
alias fontpatt returnex /^##\*#.*?#\*##\Q $+ $replacecs($1-,\E,\E\\E\Q) $+ \E$/S
on $*:text:$($fontpatt(.test)):#:{ echo -a real message is .test }

Last edited by Wims; 13/04/11 09:36 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard