String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
时间: 2023-09-26 16:10:00 浏览: 39
这个正则表达式用于匹配中国大陆手机号码。具体解释如下:
- `^` 匹配字符串的开始位置。
- `(13[0-9])` 匹配以13开头的手机号码。
- `(14[5,7,9])` 匹配以145、147、149开头的手机号码。
- `(15([0-3]|[5-9]))` 匹配以15开头,第二位为0-3或5-9的手机号码。
- `(166)` 匹配以166开头的手机号码。
- `(17[0,1,3,5,6,7,8])` 匹配以17开头,第二位为0、1、3、5、6、7、8的手机号码。
- `(18[0-9])` 匹配以18开头的手机号码。
- `(19[8|9])` 匹配以198或199开头的手机号码。
- `\\d{8}` 匹配后面8位数字。
- `$` 匹配字符串的结束位置。
因此,这个正则表达式可以用于判断一个字符串是否是合法的中国大陆手机号码。
相关问题
String regEx = "[0-9]{4}-[0-9]{2,3}";
This regular expression matches a string that has four digits, followed by a hyphen, and then either two or three digits. It can be used to match strings that represent dates in the format YYYY-MM-DD or YYYY-MM-DDD.
public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";将该字段重命名为“SQL_REGEX”,以匹配正则表达式'^[a-z][a-zA-Z0-9]*$'。
public static String sqlRegex = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";