Java Matcher appendReplacement() methodThis method is used to implement append-and-replace step. First, It replaces compiled character or word with given input sequence and then it appends the given replacement string to the string buffer. SyntaxParameterstrbuff - The target string buffer replcmnt - The replacement string ReturnsThis matcher ThrowsIllegalStateException - If no match has yet been attempted, or if the previous match operation failed IllegalArgumentException - If the replacement string refers to a named-capturing group that does not exist in the pattern IndexOutOfBoundsException - If the replacement string refers to a capturing group that does not exist in the pattern Example 1Test it NowOutput: 'Let the cat 'Let the cat come out of the bag'.To disclose a secret(cat Example 2Test it NowOutput: 'Let the cat come out of the bag'.To disclose a secret(cat)** Example 3Test it NowOutput: Start : 0 End : 3 Start : 8 End : 11 Start : 15 End : 19 -Hello-word-
Next TopicJava Matcher class
|