RegexUtils class

正则表达式工具类 提供各种正则表达式验证和处理功能

  • @Author: chuxiong
  • @Created at: 30-07-2025 18:28
  • @Email:
  • description 提供正则表达式相关的工具方法

Constructors

RegexUtils.new()
factory

Properties

cityMap Map<String, String>
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

hasMatch(String? s, Pattern pattern) bool
判断内容是否符合正则(支持Pattern类型参数)
isAlphabetic(String? s) bool
验证是否为纯字母
isAlphanumeric(String? s) bool
验证是否为字母和数字的组合
isDate(String input) bool
Return whether input matches regex of date which pattern is 'yyyy-MM-dd'. 返回输入是否匹配样式为'yyyy-MM-dd'的日期的正则表达式。
isEmail(String input) bool
Return whether input matches regex of email. 返回输入是否匹配电子邮件的正则表达式。
isHexColor(String? color) bool
验证十六进制颜色值 (#RGB, #RGBA, #RRGGBB, #RRGGBBAA)
isIDCard(String input) bool
Return whether input matches regex of id card number. 返回输入是否匹配身份证号码的正则表达式。
isIDCard15(String input) bool
Return whether input matches regex of id card number which length is 15. 返回输入是否匹配长度为15的身份证号码的正则表达式。
isIDCard18(String input) bool
Return whether input matches regex of id card number which length is 18. 返回输入是否匹配长度为18的身份证号码的正则表达式。
isIDCard18Exact(String input) bool
Return whether input matches regex of exact id card number which length is 18. 返回输入是否匹配长度为18的id卡号的正则表达式。
isInteger(String? s) bool
验证是否为整数
isIP(String input) bool
Return whether input matches regex of ip address. 返回输入是否匹配ip地址的正则表达式。
isIPv4(String? ip) bool
验证IP地址(IPv4)
isIPv6(String? ip) bool
验证IPv6地址
isJSON(String? str) bool
验证是否为有效的JSON格式
isMACAddress(String? mac) bool
验证MAC地址
isMobileExact(String input) bool
Return whether input matches regex of exact mobile. 精确验证是否是手机号
isMobileSimple(String input) bool
Return whether input matches regex of simple mobile. 判断输入字符串是否符合手机号
isNumeric(String? s) bool
验证是否为纯数字(整数或小数)
isPositiveInteger(String? s) bool
验证是否为正整数
isPostalCode(String? code) bool
验证邮政编码(中国)
isQQ(String input) bool
Return whether input matches regex of QQ. 返回是否匹配QQ的正则表达式。
isStrongPassword(String? password) bool
验证密码强度(至少8位,包含大小写字母、数字和特殊字符)
isTel(String input) bool
Return whether input matches regex of telephone number. 判断返回输入是否匹配电话号码的正则表达式
isTime(String? time) bool
验证时间格式 (HH:MM:SS)
isURL(String input) bool
Return whether input matches regex of url. 返回输入是否匹配url的正则表达式。
isUserName(String input, {String regex = RegexConstants.REGEX_USERNAME}) bool
Return whether input matches regex of username. 返回输入是否匹配用户名的正则表达式。
isZh(String input) bool
Return whether input matches regex of Chinese character. 返回输入是否匹配汉字的正则表达式。
matches(String regex, String input) bool
Return whether input matches the regex. 返回输入是否匹配正则表达式。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited