教程:http://deerchao.net/tutorials/regex/regex-1.htm
在线调试:http://regexr.com/
import java.util.regex.Matcher; import java.util.regex.Pattern; public class TestPattern { public static void main(String args[]) { Pattern pattern = Pattern.compile("(\\w+)(\\d+)"); Matcher m=pattern.matcher("regexTest30-Mins"); while (m.find()) { System.out.println(m.group()); //regexTest123 System.out.println(m.group(0));//regexTest System.out.println(m.group(1));//30 } } }
时间: 2024-10-06 05:51:10