I tried like this – To validate a point like x,y
“[0-9]{1,},[0-9]{1,}”
Its not working.
UPDATE:
I must be doing something wrong. This is a simple Console input through Scanner(System.in) – using Scanner#nextLine which returns a String.
private static String REGEX_PATTERN = "[0-9]{1,}[,][0-9]{1,}";
private static Pattern regExPattern = Pattern.compile(REGEX_PATTERN);
private static Matcher regExMatcher;
regExMatcher = regExPattern.matcher(getStringValue());
isValid = regExMatcher.matches();
I tried svrist’s solution too. It didn’t help.
It is working:
maybe
getStringValue()is returning some extra character like white-spaces or line-feeds.To ignore the spaces try with