If I use this....
var str = 'Testing123@@';
if (str.match(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!,%,&,@,#,$,^,*,?,_,~,+,\-,",',.,:,=,{,},\[,\],(,)]).{8,}/)) {
args.IsValid = true;
}
This works fine.
But I updated to try and use a StringLiteral for the '8' so in theory it could be dynamic.
var passwordMinLength = 8;
const regex = new RegExp(`^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!,%,&,@,#,$,^,*,?,_,~,+,\-,",',.,:,=,{,},\[,\],(,)]).{${passwordMinLength},}`);
if (str.match(regex)) {
args.IsValid = true;
}
Though, this returns false even though in the JS debugger the string output looks the same as the previous implementation. The 8 is showing up as expected.