mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I would like to propose a new command parameter for $regex(), like so:

$regex(name, string, pattern, command)

Thus allowing for clever handling of match strings or capture groups.

Examples: The command parameter could be used to /hadd a series of <key> <data> fields to a hash table from JSON or XML outputs. It can be used to easily break up a string of switch parameters into a series of correctly named %variables. It would add a level of convenience for handling long and complex lists without the need for building while loop, and nested while loop constructs.

Command parameters are one of the more interesting aspects of this language. smile

<Cue the Wims!>


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Nice suggestion smirk


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
bump cool

Code:
RAW 005:*: { ; ISUPPORT
  var %table = session
  noop $regex(isupport, $3-, /(?:\s:.*)|(\S+)/g, hadd -m %table $+(isupport.,$cid,.,\n) $$+(\1)) (or $$1)
}


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Feb 2015
Posts: 138
kap Offline
Vogon poet
Offline
Vogon poet
Joined: Feb 2015
Posts: 138
Hello Raccoon,

Can you please breakdown your regex with an example line so I may understand better what it does?

Kind regards


GNU Terry Pratchett - Looking for a mIRC help channel -> Check #mircscripting @ irc.swiftirc.net
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Sorry kap, it was slightly broken.

The idea being to capture space delimited tokens, but ignore everything following a space and a colon. Turns out that $1- eliminates the colon, so I had to switch to $rawmsg instead of $1-. It was just written freehand as an example, untested.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard