JavaScript - 正規表現

let w3 = "   99   "

console.log(w3.match(/^\s*[0-9]+\s*$/))
// [ '   99   ', index: 0, input: '   99   ', groups: undefined ]
 
console.log("[" + w3.replace(/^\s+|\s+$/g, "") + "]")
// [99]