is Integer String by Regex - Java java.util.regex

Java examples for java.util.regex:Match Number

Description

is Integer String by Regex

Demo Code


//package com.java2s;
import java.util.regex.Pattern;

public class Main {
    /**//from   w  w w . j av a 2  s .c o m
     * 
     * @param txt "1,2,3,4"
     * @return
     */
    public static boolean isIntegerString(String txt) {

        return Pattern.matches("\\d*|(\\d*,\\d*)*", txt);
    }
}

Related Tutorials