mIRC Home    About    Download    Register    News    Help

Print Thread
#216865 04/12/09 11:47 PM
Joined: Jul 2008
Posts: 236
S
s00p Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
Perhaps I'm confused about how it works...

From the mIRC help:
Quote:
$regex([name], text, re)

Returns N, the number of strings in text that matched the regular expression.


Am I correct if I state for example, that $regex(test,@@@@,/\@/) should return 4 instead of 1? Would someone care to offer some insight as to whether what the mIRC help file states is true, and if so elaborate/clarify? It is either incorrect (and a bug needs to be filed) or I have misunderstood the help documents (and it should be clarified).

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
The regex engine will stop after finding one match if not told to do otherwise with the /g switch.

//echo -a $regex(test,@@@@,/\@/g) will echo 4.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Or
Code:
$regex(test,$str(@,4),/[@]/g)

Joined: Jul 2008
Posts: 236
S
s00p Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
Thank you both.


Link Copied to Clipboard