Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
603a8df8
Commit
603a8df8
authored
Apr 04, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
监控字符集未匹配的特殊汉字,打印监控信息
parent
d10a846c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
ValidationUtil.java
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
+12
-2
TestValidationUtil.java
src/test/java/common/TestValidationUtil.java
+35
-0
No files found.
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
View file @
603a8df8
...
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.util;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.util.encrypt.MD5Util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Calendar
;
...
...
@@ -13,10 +14,11 @@ import java.util.regex.Pattern;
* Created by Miraculous on 15/7/6.
* 所有validate为真返回true, 否则返回false
*/
@Slf4j
public
class
ValidationUtil
{
private
static
String
phoneRegExp
=
"^1[3456789][0-9]{9}$"
;
private
static
String
chineseNameRegExp
=
"^[\u4e00-\u9f
a5]+(\\.|·)?[\u4e00-\u9fa5
]+$"
;
private
static
String
chineseNameRegExp
=
"^[\u4e00-\u9f
ff]+(\\.|·)?[\u4e00-\u9fff
]+$"
;
private
static
String
ipv4RegExp
=
"^((2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)\\.){3}(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)$"
;
private
static
String
localIpv4RegExp
=
"^((172\\.(1[0-6]|2[0-9]|3[01]))|(192\\.168|169\\.254)|((127|10)\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)))(\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)){2}$"
;
...
...
@@ -39,7 +41,15 @@ public class ValidationUtil {
return
false
;
}
Matcher
matcher
=
chinesePattern
.
matcher
(
chinese
);
return
matcher
.
find
();
boolean
valid
=
matcher
.
find
();
if
(!
valid
){
StringBuilder
uniCodeTemp
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
chinese
.
length
();
i
++){
uniCodeTemp
.
append
(
"\\u"
).
append
(
Integer
.
toHexString
((
int
)
chinese
.
charAt
(
i
)));
}
log
.
info
(
"[ValidationUtil][validateChinese]:[chinese][unicode][length]:[{}][{}][{}]"
,
chinese
,
chinese
.
length
(),
uniCodeTemp
);
}
return
valid
;
}
/**
...
...
src/test/java/common/TestValidationUtil.java
0 → 100644
View file @
603a8df8
package
common
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
@Slf4j
@RunWith
(
JUnit4
.
class
)
public
class
TestValidationUtil
{
public
static
void
main
(
String
[]
args
){
String
[][]
contacts
=
{
{
"18589336973"
,
"刘䶮"
},
{
"13198898119"
,
"张鑫鑫"
},
{
"16620800072"
,
"许慧梓"
},
{
"1508964071 "
,
"1508964071 "
},
{
"16603429800"
,
"张泽浩"
},
{
"17393151197"
,
"李小林?"
},
{
"18721920553"
,
"王正\u202D"
}};
for
(
String
[]
ctc
:
contacts
)
{
log
.
info
(
"phoneNo:[{}][{}],name:[{}][{}],name-trim:[{}][{}]"
,
ctc
[
0
],
ValidationUtil
.
validatePhoneNo
(
ctc
[
0
]),
ctc
[
1
],
ValidationUtil
.
validateChinese
(
ctc
[
1
]),
ctc
[
1
].
trim
(),
ValidationUtil
.
validateChinese
(
ctc
[
1
].
trim
()));
}
}
@Test
public
void
testString
()
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment