June 2017
Beginner
1296 pages
69h 23m
English
... 55 .mapToInt(m -> m.group().length())
56 .average().orElse(0));
57 }
58 }

The new Matcher method overloads appendReplacement (lines 24–25) and appendTail (line 29) are used with Matcher method find (line 23) and a StringBuilder in a loop to iterate through a String and replace every-regular expression match with a specified String. At the end of the process, the StringBuilder contains the original String’s contents updated with the replacements. Lines 13–26 proceed as follows:
Line 13 creates a Pattern to match—in this case, the literal characters "an".
Line 17 creates ...
Read now
Unlock full access