I\'m looking for a very simple way of getting the equivalent of something like the following JavaScript code. That is, for each match I would like to call a certain
Since Java 9 Matcher.replaceAll:
Pattern.compile("\\S+").matcher("Hello World!") .replaceAll(mr -> "" + mr.group().length());
The parameter freely named mr is a MatchResult, with access methods like mr.group(1) or mr.end() - mr.start().
mr
MatchResult
mr.group(1)
mr.end() - mr.start()