Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 带数字的regext strip字符串_Javascript_Regex - Fatal编程技术网

Javascript 带数字的regext strip字符串

Javascript 带数字的regext strip字符串,javascript,regex,Javascript,Regex,我想从这个URL中删除除5位数字以外的所有内容 我有这个[^\d],但它没有从ks1中删除1 网址: 预期产出 40069 41582 41616 实际输出(注意141582中不需要的初始值1): 使用match然后join而不是剥离: var re=/\b\d{5}\b/g; var str='/teaching resources/primary-40069/ks1-math-41582/understanding-shape-and-space-41616/position-and-d

我想从这个URL中删除除5位数字以外的所有内容

我有这个
[^\d]
,但它没有从
ks1
中删除1

网址:

预期产出

40069 41582 41616
实际输出(注意
141582
中不需要的初始值1):


使用
match
然后
join
而不是剥离:

var re=/\b\d{5}\b/g;
var str='/teaching resources/primary-40069/ks1-math-41582/understanding-shape-and-space-41616/position-and-direction-41619/';
var-m;
m=str.match(re).join(“”);

警报(m)
[^\d]+
是您所需要的
40069 41582 41616
40069 141582 41616