# 正则匹配
# 说明
正则匹配包含了一些常用的通过正则验证字符串的方法,导出模块名为regExp
- 导入模块
import { regExp } from 'gx-instant'
# 方法
# isEmail
说明:正则验证-邮箱
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isTel
说明:正则验证-国内手机号
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isID
说明:正则验证-身份证号
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isURL
说明:正则验证-URL
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
示例
isURL('http://www.baidu.com') //true
# isIPv4
说明:正则验证-ipv4地址
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isRGBHex
说明:正则验证-颜色的16进制
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
示例
isRGBHex('#00FF00') //true
# isDateStr
说明:正则验证-日期字符串
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
提示:此方法验证日期字符串是否符合日期正则,而非验证是不是Date类型
示例
isDateStr('2023-01-02') //true
# isQQ
说明:正则验证-QQ号
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isWX
说明:正则验证-微信号
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# isPlate
说明:正则验证-车牌号
- 参数
str: string
验证字符串
- 返回:
boolean
验证结果
# is
说明:正则验证-自定义
- 参数
regExp: regExp
正则表达式str string
验证字符串
- 返回:
boolean
验证结果