标签:int .com ring mat 字符串 字符 static div exp
package dodo; import java.util.regex.Matcher; import java.util.regex.Pattern; public class demo { static String cmd="export_20170717_out.log"; public static void main(String[] args) { String regex="\\d{8}"; Pattern pa=Pattern.compile(regex); Matcher ma=pa.matcher(cmd); if(ma.find()){ System.out.println("取到的日期为:"+ma.group(0)); } } }
输出结果为:
取到的日期为:20170717
在一串字符串中找到与正则表达式匹配的字符串?(例如:export_20170717_out.log 找到20170717)
标签:int .com ring mat 字符串 字符 static div exp
原文地址:http://www.cnblogs.com/ranrongzhen/p/7193511.html