I want to be able to search the plist of a selected action or actions (or perhaps a selected macro), finding any variables that start with “zz”. I almost got it working, but I ran into some snags.
BTW, I don’t need to find matches in AppleScript or Javascript (but it’s probably OK if I do find them), because if they reference one of these “zz” variables, I will already have found them in the other actions (in theory). But let’s ignore that for now.
So I figure I could search for “zz” preceded by “>” or “%” (or possibly a space, but I don’t think so), and followed by “<”, “%”, or “.” (the latter for things like “position.x”). In other words, a regex like this:
(?<=[>%])(zz.*)(?=[%<.])
Assuming I could get it to only return matching strings, I could run it through sort and uniq so I had a sorted unique list of variables that start with “zz”.
So, I tried exporting the selected action(s) to a file, and doing a shell script:
grep -O ‘(?<=[>%])(zz.*)(?=[%<.])’ [file name]
But apparently OS/X grep doesn’t support lookaheads/lookbehinds.
I also tried BBFind (BBEdit command-line tool), and it works (I think) except it won’t return just the matches.
I want to use this to be able to automatically build a list of variables that should be cleaned up at the end of a macro, and I figured I’d identify those variables by preceding them with “zz”, which I already do anyway, to identify variables that don’t need to persist from macro run to macro run.
Anyone got any ideas? It’s frustrating because I’m close.