java正则笔记

1、匹配数字 \d

 Pattern compile = Pattern.compile("\\d");
 Matcher matcher = compile.matcher(str);

 

2、匹配多个 \d+

 Pattern compile = Pattern.compile("\\d+");
 Matcher matcher = compile.matcher(str);

3、匹配数字开头 ^\d+

 Pattern compile = Pattern.compile("^\\d+");
 Matcher matcher = compile.matcher(str);

你可能感兴趣的:(笔记,正则表达式,java)