diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts index 89453f316aebe..c644809c11ab7 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts @@ -172,7 +172,7 @@ export class DistributedMap extends MapBase implements INextable { errors.push('label must be 40 characters or less'); } - let labelRegex = new RegExp('[\s\?\*\<\>\{\}\\[\\]\:\;\,\\\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]', 'gi'); + let labelRegex = /[\s\?\*\<\>\{\}\\[\]\:\;\,\|\^\~\$\#\%\&\`\"]|[\u0000-\u001f]|[\u007f-\u009f]/gi if (labelRegex.test(this.label)) { errors.push('label cannot contain any whitespace or special characters'); }