我有一个 JS 正则表达式。
var t1 = str.match(/\[h1\]/g).length;
If str包含这个词[h1]它工作正常,否则显示错误!如何解决问题?
str
[h1]
var t1 = (str.match(/\[h1\]/g)||[]).length;