trigger match on a mush serialized string variable

Posted by Dakine on Thu 23 Apr 2015 07:58 PM — 3 posts, 15,033 views.

#0
Is it possible to match on an element in a serialized string variable?

At the moment I can use something like this setup:


Example of one of the variables

<variable name="potname">"heal"</variable>


I can use this in a trigger match like this.

^You\sdrop(?:[ ]+(\d+))?(\s\*){0,1}\s(@potname).$


With the correct settings i.e expand variables this matches correctly.

However, since I've serialized my variables i'm stuck on the syntax how to put this into a trigger if this is something you can do.

An example variable would be:

<variable name="potVars">{
  potname = "heal",
  potnum = "28",
  }</variable>



doing the below doesn't work.

^You\sdrop(?:[ ]+(\d+))?(\s\*){0,1}\s(@potVars.potname).$



I could check for the exact match by sending the wildcard to a script, however, I believe this would be a lot less efficient by firing the script a great deal more. Is that assumption correct?
The other option is creating a single variable with the desired value so the first instance worked.

Dak
Australia Forum Administrator #1
I think I would send the wildcard to a script. Whilst that might fire more often, how many lines do you receive with "You drop xxx" in them? Not all that many, I bet, and once you are in the script a simple table comparison would see whether or not you dropped the item you are interested in.

Bear in mind that expanding variables itself takes time (not a lot of time, but time) as the client has to "recompile" the regular expression every time. Fixed regular expressions don't need to be recompiled (ie. one without "expand variables" in them).
#2
Hi Nick,

That makes sense. I was also just looking at your gag example thread
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3958

more specifically, using the function(s) ArrayCreate etc, however, will keep that as something useful to remember and send the wildcard to a script.

Dak