package com.tszr; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { public static void main(String[] args) { String str = "[003][002][004][006]"; Pattern pattern = Pattern.compile("(\\d+)"); Matcher matcher = pattern.matcher(str); while (matcher.find()) { System.out.println(matcher.group(1)); } } }