标签: javascript jquery regex
我有以下字符串:
PR-1333 | testtt
我想在javascript中使用正则表达式获取数字1333。我怎样才能做到这一点?
答案 0 :(得分:0)
这将在您的文字中查找数字。
var text = "PR-1333|testtt"; var number = text.match(/\d+/g); // this returns an array of all that it found. console.log(number[0]); // 1333