Regular expressions in JS always return false

var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
str = "411432199911112020";

if(!pattern.test(str)){
    console.log(pattern);
    alert("")
}
//pattern: /(^\d15$)|(^\d18$)|(^\d17(\d|X|x)$)/,
//{}
//[][1]
//dtcms



Jun.24,2022

if the code you write is executed in a JS file or in a browser developer tool, the printed pattern is normal. The problem description says that the curly braces in the pattern printed by console.log are gone, and it is seriously suspected that this code is written in a view engine. Curly braces have a special meaning in this corresponding view engine, such as output variables, {15} directly output constant 15, it seems that the curly braces have disappeared.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea4683-47a99.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea4683-47a99.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?