记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
董敬伟
liquidnet-bus-v1
Commits
ab80495a
Commit
ab80495a
authored
Aug 01, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加特殊字符过滤
parent
d391a743
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
StringUtil.java
...main/java/com/liquidnet/commons/lang/util/StringUtil.java
+27
-4
No files found.
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/StringUtil.java
View file @
ab80495a
...
...
@@ -447,10 +447,6 @@ public abstract class StringUtil {
sb
.
append
(
right
(
bankId
,
4
));
return
sb
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
isEmail
(
"123@qq.com"
));
}
public
static
boolean
isBlank
(
CharSequence
cs
)
{
...
...
@@ -598,4 +594,31 @@ public abstract class StringUtil {
}
return
false
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
isEmail
(
"123@qq.com#$%^&*()"
));
String
regEx
=
"[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]"
;
//可以在中括号内加上任何想要替换的字符,实际上是一个正则表达式
String
aa
=
""
;
//这里是将特殊字符换为aa字符串," "代表直接去掉
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
"原字符串"
);
//这里把想要替换的字符串传进来
String
newString
=
m
.
replaceAll
(
aa
).
trim
();
System
.
out
.
println
(
"newString====="
+
newString
);
//将替换后的字符串存在变量newString中
//方法二 如果第一种太麻烦可以直接用下面的
String
str
=
"#$%^&*()我的正确#$%^&*()原字符串#$%^&*()"
;
String
newString2
=
str
.
replaceAll
(
regEx
,
aa
).
trim
();
//不想保留原来的字符串可以直接写成 “str = str.replaceAll(regEX,aa);”
System
.
out
.
println
(
"newString2====="
+
newString2
);
}
}
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