mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 38
S
snabbi Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2003
Posts: 38
Hi there,

I noticed that you are not able to use brackets in an on text event with regular expressions. This makes it impossible to use grouping. I think it is a bug, but perhaps there is a workaround.

I have tried to solve it with $chr(40) and stuff but haven't found a solution yet.

Using mirc 6.3 and example code:
on $*:TEXT:/(?:a)/:#: { echo -a test } <-- doesn't work
on $*:TEXT:/a/:#: { echo -a test } <-- does work

Joined: Aug 2007
Posts: 13
L
Pikka bird
Offline
Pikka bird
L
Joined: Aug 2007
Posts: 13
Confirmed.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The issue isn't from the brackets. Grouping is in fact allowed in the matctext, and works.

You cannot use : inside the text of a matchtext, as mIRC will parse that as the end of the matchtext delimiter, that is why your example fails.

The following example proves that it works fine:

Code:
on $*:TEXT:/(.)/:#:echo -a $regml(1)



- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Sep 2003
Posts: 38
S
snabbi Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2003
Posts: 38
This makes sense, thnx

Still I think mIRC could ignore the : inside the / / of the pattern. Thnx though. No backrefs are needed but it is a workaround for grouping.

Joined: May 2007
Posts: 89
T
Babel fish
Offline
Babel fish
T
Joined: May 2007
Posts: 89
I'm not sure if I'm right because I didn't test this but maybe you're using the regular expression facility in events incorrectly.

According to the help file:
Originally Posted By: mIRC's 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-.


Rather than just using /pattern/options, why not use m/pattern/options ? The leading m is used by the PCRE library to allow change in the expression's delimiters. Thus, with the leading m, one could write m@pattern@options, and this would function correctly if no '@' or atleast the '@'s are escaped if present in the pattern.

What I think is that mIRC uses this PCRE possibility to know where to stop its parser when parsing an event's header. Although the help file says that the 'm' is optional (which is true though), maybe it can be used when you want to include a ':' in your pattern. smile

I'm just supposing all that without any tests being done. Sorry if I'm not right. :s

An for the new year, Have Good Times !

Cordialement


tropnul
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
That wouldn't work, mIRC parses the line first tokenizing by : ( i assume)

i.e:
on $*:TEXT:m/:/:#:echo -a message: $1-
would mess up the token count.

so even if you did
on $*:TEXT:m@:@:#:echo -a message: $1-
It would break it.

a simple alternative is to use \072 for :
on $*:TEXT:/\072/:#:echo -a message: $1-

or if your really concerned about backreferencing

on $*:TEXT:$(/(? $+ $chr(58) $+ a){3}(b)/):#:echo -a message: $1- regml: $regml(0) $regml(1)


$maybe

Link Copied to Clipboard