Last active
March 9, 2021 12:46
-
-
Save datfinesoul/1b892e632a27607e335d59d2fa72aabb to your computer and use it in GitHub Desktop.
Ability to split regex into multiple lines and add comments in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const partition = "aws-cn"; | |
const multilineRegex = (...rest) => new RegExp(rest.map(x => (x instanceof RegExp) ? x.source : x).join('')); | |
const re = multilineRegex( | |
/aws:/, // I can COMMENT!!!! | |
partition, | |
/:secretsmanager:cn-north-1:111111111111:/ | |
); | |
console.log({ | |
a: re.test('aws:aws:secretsmanager:cn-north-1:111111111111:'), | |
b: re.test('aws:aws-cn:secretsmanager:cn-north-1:111111111111:') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment