Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Regex which return content from each group
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
Main main = new Main();
String input = "[0-9]{1,13}";
String regex = "\\[.*]\\{([0-9]+),([0-9]+)}";
Pattern pattern = Pattern.compile(regex);
try {
Matcher matcher = pattern.matcher(input);
main.print(input, matcher);
}catch (Exception e){
public void print(String input, Matcher matcher){
System.out.println("Input: " + input);
System.out.println("Matches? " + matcher.matches());
System.out.println("Groups: " + matcher.groupCount());
System.out.println("Min: " +;
System.out.println("Max: " +;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.