mIRC Home    About    Download    Register    News    Help

Topic Options
#263939 - 13/10/18 09:32 PM New $regex() command parameter.
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
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!

Top
#263943 - 14/10/18 12:05 AM Re: New $regex() command parameter. [Re: Raccoon]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3503
Loc: France
Nice suggestion smirk
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#265086 - 28/02/19 08:21 PM Re: New $regex() command parameter. [Re: Wims]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
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!

Top
#265087 - 01/03/19 10:12 AM Re: New $regex() command parameter. [Re: Raccoon]
kap Offline
Ameglian cow

Registered: 19/02/15
Posts: 38
Loc: Vlissingen, The Netherlands
Hello Raccoon,

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

Kind regards
_________________________
Script in mSL? Want to learn git and share/wiki your code? Repo's @ https://www.mircscripts.nl!

Top
#265089 - 02/03/19 05:09 AM Re: New $regex() command parameter. [Re: kap]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
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!

Top