mIRC Home    About    Download    Register    News    Help

Print Thread
#260074 25/02/17 04:18 PM
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
The help file says:

> Subtext can also contain special markers where \0 = number of matches, \n = match number, \t = match text, \a = all match items, and \A which is a non-spaced version of \a.

//echo -a $regsubex(123:abc 456:def 789:ghi,/(\d+):(\w+)\s?/g,( $+ \t $+ ))

Returns: (123)(abc)(456)

Expected: (123:abc )(456:def )(789:ghi)
Otherwise: (123abc)(456def)(789ghi) ?

\t is only behaving as \1, and has a tracking problem with /g when multiple backrefs exist.

I would expect \t to reference the "matchtext that is about to be replaced." so the user can do something about it. It doesn't say anything about backref match text. Just [/pattern/] match text.

Consider the behavior of this pattern (that has no backrefs): $regsubex(abcdefg,/./g,$asc(\t))

Last edited by Raccoon; 25/02/17 05:02 PM.

Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,157
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,157
This post explains how \t works.
I do not believe the behavior of \t is a bug, however, I'm wondering why was \t added in the first place, because without /g, it's only going to return the first captured group (not that useful), the same as \1, but \1 is what most implementations of PCRE use to refer to captured groups, and with /g, well I can't see the logic and how it can be useful.


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

Link Copied to Clipboard