js正则问题

"25...........................WireGuard Tunnel #2".replace(/[0-9]+/, "")

这样写只能把25替换掉,我想提取前面的25

阅读 1.5k
2 个回答

"25...........................WireGuard Tunnel #2".match(/[0-9]+/)?.[0]

"25...........................WireGuard Tunnel #2".replace(/(\d+).*$/, "$1")

// 25
推荐问题