💾 Archived View for cfdocs.wetterberg.nu › cfn-regexes.gemini captured on 2024-08-25 at 01:58:26. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Using regular expressions in AWS CloudFormation templates

Search

Regular expressions (commonly known as regexes) can be specified in a number of places within an AWS CloudFormation template, such as for the `AllowedPattern` property when creating a template parameter.

parameter

Regular expressions in AWS CloudFormation conform to the Java regular expression syntax. A full description of this syntax and its constructs can be viewed in the Java documentation, here: java\.util\.regex\.Pattern.

java.util.regex.Pattern

Since AWS CloudFormation templates use the JSON syntax for specifying objects and data, you will need to add an additional backslash to any backslash characters in your regular expression, or JSON will interpret these as escape characters.

For example, if you include a `\d` in your regular expression to match a digit character, you will need to write it as `\\d` in your JSON template.