I think the mistake is actually that Tinderbox, certainly at present (i.e. for later readers, v8.9.1), simply cannot backslash-escape single or double straight quotes. Bear in mind that Tinderbox core design long predates Markdown and action code is an evolved macro system and not a coding environment from the ground up. So, coding edge-case are likely to exist (and, I suspect) not easy to retro fix. Not least because the ability to escape straight quotes was first asked for long ago and hasn’t been taken up.
In this case, I’d use the approach you intimated. Try:
Note, neither .beginsWith() nor .endsWith() will match a " character - I tried! But if you wanted to test/trim separately for font-only or back-only quotes you could replace the second line above with these two tests:
Clarification. .beginsWith() nor .endsWith()do work in agents (and will match a "), but seemingly the operators don’t work at all as a test in if() conditional queries. I’ve reported this.
Well, you’ll find that I lifted my solution from my notes on String.substr().
You might also want to see my recently revised notes on using regex back-references. In looking at it now, I need to clarify if backreferences are included in a quoted string or not. IOW, if $Text is “Hello to you.”:
all generate the string “Hello and you”. So it’s flexible, but—note to self—I think it helps the learner to say so. Most ‘code’ usage is not intuitive before the fact (except to those with some coding experience and even then they may guess wrongly first time).