Tip: Escaping curly brackets for substitutions in ActionScript

In ActionScript, Relevance Substitutions are delimited by { } symbols.

When you need a literal open curly bracket {, without beginning a Relevance Substitution, escape it by doubling it to {{

When you are inside a relevance Substitution, and need a literal } without ending the substitution, double it up as }}

Inside a substitution, the literal { does not need to be escaped; outside of a substitution, the literal } does not need to be escaped.

Here’s an example with both cases

//Escape the literal `}` in the GUID so it does not end the relevance substitution.  Inside a substitution the `{` does not need to be escaped.

if {exists key "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{B5BACF37-1A3C-4923-ADD7-5AEDA14740ED}}" of registry }

//Escape the literal `{` in the GUID so it does not begin a relevance substitution.  Outside a substitution the `}` does not need to be escaped.

regkeydelete "[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{{B5BACF37-1A3C-4923-ADD7-5AEDA14740ED}]"
8 Likes

5 posts were split to a new topic: Regular Expression matching in Mac