mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2005
Posts: 11
B
botanic Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2005
Posts: 11
By Reference to mIRC Help File, :-
The $ prefix
Indicates that the matchtext section of a definition contains a regular expression.

on $*:TEXT:m/regular expression/switches:#:/echo message: $1-

The 'm' and switches are optional. The // are required. If switches are used they must be standard PCRE switches, otherwise the match will fail. You can use switch 'S' to strip control codes from $1-.

and reference to PCRE


i make this testing script :-

on $*:TEXT:m/$regex($1-,/[[:^digit:]]/g)/P{IsDigit}:#:/echo message: $1-

But, nothings appear.
Any wrong with my script?...

Last edited by botanic; 12/01/05 04:08 AM.
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, a couple of things.

  • Since semi colons : are used in the on TEXT event to delimit channels and matchtext, they cannot be used in the matchtext. The option is to use the short hand character class \D instead of [[:^digit:]], or to specify a wildcard * as matchtext, and specify an: if $regex(...) {

    on *:TEXT:*:#: if ($regex(input,/expression/modifiers)) { do things }
  • If you use the $ event prefix to use a regex in the matchtext part, then you don't specify the $regex identifier, you put the expression right away like:

    on $*:TEXT:/\D+/:#: echo -a matched 1 or more non-digit characters
  • The m isn't needed, since you are grouping your expression between slashes / /. Just use the m if you want to chose other seperators than / /.
  • I don't know the /P{isdigit} construct, I think you meant to put \P{..} ? I'm fairly sure that the mIRC regex does not support Unicode character properties. Wouldn't that be \P{N} anyway, as in "match a character that isn't a number" ?
  • I see you use the g modifier after [[:^digit:]]/. I think the g modifier only works when putting it after the last slash /g of the expression.

  • It would help a lot if you told us what exactly you are trying to match. Btw I'm by no means a regex guru, I have basic knowledge, enough to get around in mIRC.

Greets

Last edited by FiberOPtics; 12/01/05 04:51 AM.

Gone.
Joined: Jan 2005
Posts: 11
B
botanic Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2005
Posts: 11
Thanks, and now i know it cannot work. smile
for ur information, i want make a number game. just a newbie idea. smile and i want to know how ON $*:TEXT:m/regex/:#: works.

so, thank to tell me about the D+,

more question : is it logic if ON $*:TEXT:*:#: { if ($regex(input,/expression/modifiers)) { do things } } ?
is the $* will work ?

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
No, if you're gonna put * as matchtext, and use the $regex in an if condition, then lose the $ event prefix.

So: on *:TEXT:*:#: if $regex(....) { commands }

Btw, maybe I can help you, what would you like to match?

Greets


Gone.
Joined: Jan 2005
Posts: 11
B
botanic Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2005
Posts: 11
just a crazy idea... frown

i like to match what number i want....
this game like a "mastermind". But everyone in channel can try and only use number. no others characters..

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well you don't need a regex for that.

Suppose your number is stored in variable %mm.number

Then you do: on *:TEXT:$(%mm.number):#: msg # $nick guessed the right number %mm.number

The $( ) construct allows you to put variables or identifiers in the matchtext, so that they are evaluated, and checked for their values.

So if %mm.number is 888, and someone types 888, your code will msg the channel saying they guessed the right number.

Perhaps you could add a trigger like !mm <number> which would go as follows:

on *:TEXT:$(!mm %mm.number):#: msg # $nick guessed the right number %mm.number

Greets


Gone.
Joined: Jan 2005
Posts: 11
B
botanic Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2005
Posts: 11
thanks... u are helping me too much. LOL!

so, i will use the on *:TEXT:$(!mm %mm.number):#: { whatever }

thanks again.. :P

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
No problem, glad to help.


Gone.
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I should note that in the case of single variables for matchtext and locationpart, the eval brackets $() are not needed. They are however needed for identifiers, no matter what case.

So something like:

on *:TEXT:%matchtext:%channels: will work fine

However if you want to put multiple strings in the matchtext part, you need to use eval as explained in the above posts.

on *:TEXT:$(!trigger %matchtext):%channels: will work fine

etc.


Gone.

Link Copied to Clipboard