Leanote's Blog
I love Leanote!
Toggle navigation
Leanote's Blog
Home
Chrome
Git
Linux
Windows
Others
工具大全
VsCode
Expo
Html
JavaScript
Npm
Node
Mock
React-Native
React
TypeScript
小程序
插件
正则
Dva
Ant-Design-React
Umi
Vue
Vux
Ant-Design-Vue
Http
Java
flutter
开发小工具
About Me
Archives
Tags
js拼接动态正则
2021-05-17 10:05:26
11
0
0
admin
### **使用eval(), 注意"\"需要转义** ``` var a = 1 var reg = `\/^.{${a}}$\/` eval(reg).test("1") // true eval(reg).test("11") // false ``` ### **使用new RegExp()** ``` var a = 1 var reg = new RegExp(`^.{${a}}$`, "gi") // gi可选 eval(reg).test("1") // true eval(reg).test("11") // false
Pre:
a标签下载文件和图片
Next:
element-ui表单自定义常用验证
0
likes
11
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.