Java Matcher end() MethodThis method is used to return the index of the last character matched. To find the offset of the last character matched, we need to use the find method to match the pattern character by character. SignatureThere are three types of end methods in java.
Specified byend in interface MatchResult ReturnsThe offset after the last character matched ThrowsIllegalStateException - If no match has yet been attempted, or if the previous match operation failed Example 1Test it NowOutput: Both are matching till 10th character Example 2Test it NowOutput: End position of Matching String java 5
Next TopicJava Matcher class
|