File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
lite/src/main/java/com/pengxh/kt/lite/extensions Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ fun String.formatToYearMonthDay(): String {
145
145
* 判断输入的是否是数字
146
146
*/
147
147
fun String.isNumber (): Boolean {
148
- val regex = Regex (" [-+]?\\ d+(\\ .\\ d+)?" )
148
+ val regex = Regex (" ( [-+]) ?\\ d+(\\ .\\ d+)?" )
149
149
return this .matches(regex)
150
150
}
151
151
@@ -181,8 +181,7 @@ fun String.isPhoneNumber(): Boolean {
181
181
return if (this .length != 11 ) {
182
182
false
183
183
} else {
184
- val regExp =
185
- " ^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\ d{8}\$ "
184
+ val regExp = " ^1[3-9]\\ d{9}\$ "
186
185
val regex = Regex (regExp)
187
186
this .matches(regex)
188
187
}
@@ -195,7 +194,7 @@ fun String.isEmail(): Boolean {
195
194
return if (this .isBlank()) {
196
195
false
197
196
} else {
198
- val regExp = " ^\\ w+([-+.] \\ w+)*@ \\ w+([-.] \\ w+)* \\ .\\ w+([-.] \\ w+)* \$ "
197
+ val regExp = " ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+ \\ .[a-zA-Z]{2,} \$ "
199
198
val regex = Regex (regExp)
200
199
this .matches(regex)
201
200
}
You can’t perform that action at this time.
0 commit comments