Java Matcher start() MethodThis method is used to return the start index of the previous match. To return the offset of first matched character, we need to use the find method to match the pattern character by character. SignatureThere are 3 types of start method in java. The signature of the start methods is given below.
Specified by:start in interface MatchResult Returns:The index of the first character matched Throws:IllegalStateException- If no match has yet been attempted, or if the previous match operation failed Example 1Test it NowOutput: Start position :1, End position : 4 Start position :4, End position : 7 Start position :7, End position : 10 Example 2Test it NowOutput: start position of Matching String java 2 Example 3Test it NowOutput: Start position of matching 5
Next TopicJava Matcher class
|