当前位置:网站首页>JS to verify whether the string is a regular expression
JS to verify whether the string is a regular expression
2022-06-25 14:19:00 【jason_ renyu】
js Verify that the string is a regular expression , Correct return true, Otherwise return to false.
const isRegExp = (v) => {
return Object.prototype.toString.call(v) === '[object RegExp]';
}
// Example
const reg = /[0-9a-z]/;
console.log(' Regular or not reg:', isRegExp(reg)); // Output true
console.log(' Regular or not reg:', isRegExp(/[0-9a-zA-Z]+/g)); // Output true
console.log(' Regular or not reg:', isRegExp('[0-9a-zA-Z]+')); // Output false, Must be a complete regular band // Of
console.log(' Regular or not reg:', isRegExp('')); // Output false
console.log(' Regular or not reg:', isRegExp(1111)); // Output false
边栏推荐
- Two methods to rollback the code in pycharm to the specified version (with screenshot)
- k线图24种经典图解(影线篇)
- 多臺雲服務器的 Kubernetes 集群搭建
- shell 数组
- Is it safe for Guosen Securities to open an account?
- Numpy库使用入门
- Basic usage of markdown (plain text and grammar)
- 国信证券股票开户是安全的吗?
- Nr-arfcn and channel grid, synchronous grid and GSCN
- Kubernetes cluster construction of multiple ECS
猜你喜欢

Nine parts of speech and nine tenses in English

Where can the brightness of win7 display screen be adjusted

Settings the PC must be turned on

Kubernetes cluster construction of multiple ECS

Does stream even have application advanced learning? As a programmer, you know what

Deeply understand the mathematics behind deep neural networks (mysteries of neural networks Part I)

How does hash eagle, the founder of equity NFT, redefine NFT and use equity to enable long-term value?

JVM uses tools to analyze classic cases of OOM

Logistic Regression VS Linear Regression

What if the CPU temperature of Dell computer is too high
随机推荐
sigmoid函数sigmoid求导
电脑必须打开的设置
Qt内存映射
Explain the possible memory leaks caused by the handler at one time and the solutions | the developer said · dtalk
Laravel8 implementation of picture verification code
Numpy库使用入门
Installation and removal of MySQL under Windows
Untiy force refresh UI
API encapsulation of uniapp applet
mysql数据库压缩备份_Mysql备份压缩及恢复数据库方法总结
解决报错:Creating window glfw ERROR: GLEW initalization error: Missing GL version
通达信股票账户开户安全吗
Why should programmers be softer?
shell 数组
Typescript and go --- essence
Getting started with shell variables
Beego--- notes
Garbage collection mechanism
[proteus simulation] 51 MCU +ds1302+lcd1602 display
分享自己平时使用的socket多客户端通信的代码技术点和软件使用