SOURCE

var str = 'HF1212 0 34 56 89 HFs2121-PC 1 34 56 HF001 3 45'
var pattern = /(HF.+?\s)/g

pattern.test(str)
console.log(pattern.lastIndex - RegExp.$1.length)

pattern.test(str)

console.log(pattern.lastIndex - RegExp.$1.length)

pattern.test(str)

console.log(pattern.lastIndex - RegExp.$1.length)
pattern.test(str)

console.log(pattern.lastIndex)
console 命令行工具 X clear

                    
>
console