Commit 8abdb5cd8fd2dd3461ea364ea62afd1e3ae84023
1 parent
d2ddaeb8
Exists in
master
增加sn判断是否是整数
Showing
1 changed file
with
12 additions
and
0 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
... | ... | @@ -32,6 +32,8 @@ import java.io.UnsupportedEncodingException; |
32 | 32 | import java.text.SimpleDateFormat; |
33 | 33 | import java.util.*; |
34 | 34 | import java.util.List; |
35 | +import java.util.regex.Matcher; | |
36 | +import java.util.regex.Pattern; | |
35 | 37 | |
36 | 38 | @Component |
37 | 39 | @Slf4j |
... | ... | @@ -380,6 +382,16 @@ public class MyTask implements ApplicationRunner { |
380 | 382 | return cardR; |
381 | 383 | |
382 | 384 | } |
385 | + public final static String REGEX_POSITIVE_INTEGER = "^\\+?[1-9]\\d*$"; | |
386 | + | |
387 | + private boolean isMatch(String regex, String orginal) { | |
388 | + if (orginal == null || orginal.trim().equals("")) { //$NON-NLS-1$ | |
389 | + return false; | |
390 | + } | |
391 | + Pattern pattern = Pattern.compile(regex); | |
392 | + Matcher isNum = pattern.matcher(orginal); | |
393 | + return isNum.matches(); | |
394 | + } | |
383 | 395 | |
384 | 396 | /** |
385 | 397 | * 大华设备考勤记录 | ... | ... |