最近用到的做一下记录
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
String name =
"10310"
;
//以非0数字开头的数字串
Pattern p = Pattern.compile(
"^[1-9]+\\d*"
);
Matcher m = p.matcher(name);
System.out.println(m.matches());
//以数字.数字.数字.数字格式的串
Pattern pt = Pattern.compile(
"\\d*[.]\\d*[.]\\d*[.]\\d*"
);
Matcher ma = pt.matcher(
"p=10.10.10"
);
System.out.println(ma.matches());
//以{内容},{内容}...{内容}格式的串
String test =
"{fdfdfdfdfdfdfd}"
;
Pattern ptw = Pattern.compile(
"(\\{[^{},]*\\}[\\,]*[\n\r]*){1,}"
);
Matcher maw = ptw.matcher(
"{gfdgfd}"
);
System.out.println(maw.matches());
//以数字,数字,....,数字格式的串
Pattern ptwe = Pattern.compile(
"[(\\d+)\\,(\\d+)]*"
);
Matcher mawe = ptwe.matcher(
"333"
);
System.out.println(mawe.matches());
|
|
1
|
|
本文转自sucre03 51CTO博客,原文链接:http://blog.51cto.com/sucre/1350039,如需转载请自行联系原作者