|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Sun Jul 12, 2009 8:53 am
Trigger convert to regex function |
I'm trying to clean up some... 200 or so simple lazy-mans triggers, most of them aren't anchored, and are zscript not regex.
Anyway... I started to make a LUA alias to convert simple patterns from zscript to regex, it grew and got ugly, and now, well could a reference on the lua zs.trigger object, maybe .makeregex, that does the same thing as that nice lil green arrow next to the regex option for triggers? |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 12, 2009 11:04 am |
Making your triggers into regexes doesn't do much, though. The first time the trigger's run, the zScript pattern is converted into a regex which is compiled. Converting your trigger will give you a very minor speed increase (the convert step is likely to pale in comparison to the compile step) for a lot of additional ballache. If you're not using a feature of regex that isn't emulated in zScript's patterns, you might as well leave them.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jul 13, 2009 4:03 am |
And actually, the RegEx triggers also get run through a "convert" step to deal with any variable references. So basically, zScript and RegEx triggers are exactly the same speed. RegEx is generally more complicated to understand and support later. So unless you are a real RegEx guru and prefer that syntax over the zScript syntax, or unless (as Fang says) you are doing something in RegEx that can't be done in zScript, you should really just stick with zScript. It will be easier for others to understand your scripts if you want to share them later.
|
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Wed Jul 15, 2009 2:18 pm |
Hmmm, I had considered that regex might be no faster than zscript patterns, was largely just a preference/consistency/additional options thing.
|
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
|
|