【发布时间】:2016-06-13 11:34:30
【问题描述】:
这是我的代码
"test.html".replace(/(?=\.[^.]+$)/g, Math.floor((Math.random() * 1000000) + 1))
如何将 test.html 转换为 38475.html 之类的随机 number.html?
【问题讨论】:
-
你必须使用正则表达式吗?
-
"test.html".replace(/^.+(?=\.[^.]+)/, Math.floor((Math.random() * 1000000) + 1)) -
regex101.com 是你的朋友
标签: javascript regex