Java Matcher region() MethodThe region method of Matcher class is used to limit the matcher's region by specifying the start and end point of the matcher input sequence. This method resets the matcher and then sets the region to start at the index specified by the start parameter and end at the index specified by the end parameter. Syntax:Parameterstart - The index to start searching at (inclusive) end - The index to the end searching at (exclusive) Returnsthis matcher ThrowsIndexOutOfBoundsException - If start or end is less than zero, if the start is greater than the length of the input sequence, if the end is greater than the length of the input sequence, or if start is greater than the end. Since1.5 Example 1Output: 1 Capturing Group, (a*b) Match String end(): 7 2 Capturing Group, (a*b) Match String end(): 14 java.util.regex.Matcher[pattern=(a*b)(java) region=0,15 lastmatch=aabjava] Example 2Output: 1 Capturing Group, (a*b) Match String end(): 7 java.util.regex.Matcher[pattern=(a*b)(java) region=2,10 lastmatch=bjava] Next TopicJava-matcher-start-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India