Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java regex check if group exists

String  text    = "asdf 2013-05-12 asdf";
String  regex   = ".+?([0-9]{4}s?-s?[0-9]{2}s?-s?[0-9]{2}).+";
Matcher matcher = Pattern.compile(regex).matcher(text);

if (matcher.matches()) {
    String matchedGroup = matcher.group(1);
    System.out.println(matchedGroup);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #regex #check #group #exists
ADD COMMENT
Topic
Name
7+9 =