java正则使用
作者:
Vijay_ | 来源:发表于
2018-03-02 09:41 被阅读4次
String regex = "正则";
Pattern pattern = Pattern.complie(regex);
String[] strArr = pattern.split("需要正则切割的字符串");
String regex = "正则";
Pattern pattern = Pattern.complie(regex);
Matcher matcher = pattern.matcher("需要处理的字符串");
matcher.find();//返回布尔值 表示是否能捕获到
log(matcher.group(0));
log(matcher.group(1));
...
Pattern pattern = Pattern.compile(".{3}abc.{3}");
Matcher matcher = pattern.matcher("asdabcasd");
boolean b = matcher.matches();
System.out.println(b);//true
本文标题:java正则使用
本文链接:https://www.haomeiwen.com/subject/fpboxftx.html
网友评论