Important
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.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-regexes.html
The very same applies to your \s
expressions. Use \\s
and it works.
EDIT:
Looking back the question I started to wonder the missing quotation marks on your definition. I found out the expessions are yaml format that is the second way to define things in aws.
If you should follow the yaml syntax, the right way to give string values is like this:
AllowedPattern = '/[^\s@]+@[^\s@]+\.[^\s@]+/'
https://aws.amazon.com/blogs/aws/aws-cloudformation-update-yaml-cross-stack-references-simplified-substitution/
EDIT:
Use quotes if your value includes special characters, (e.g. :, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, ).
https://stackoverflow.com/questions/19109912/do-i-need-quotes-for-strings-in-yaml