Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to find the starting point of the first subgroup

Java: How to find the starting point of the first subgroup
{filelink=6445}

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Regex_Group
 {
  public static void main(String args[])
  	 {
  	// Matching hour
    Pattern date_patern = Pattern.compile("(([0-2]?[0-9]):([0-5][0-9]))");
    String my_date = "02:59"; // test this date
    Matcher matcher = date_patern.matcher(my_date);
     if(matcher.matches())
     {
     	// print the number of group
     	 System.out.println (matcher.groupCount()); // "3"
     	// Find and display the starting index of the first group
    	int nextIndex = matcher.start(1);
    	System.out.println(nextIndex);  // "0"
     }
  }
}

Users who found this page were searching for:

  • form["user"].value python
  • HOW+TO+UNDERLINE+TEXT+IN+JAVA
  • python attaching files to an email
  • perl program for factorial of a number
  • python iterating through passwords

No comments yet.

Leave a Comment