In JavaScript it's possible to use lambda functions with the replace function, in Java string.replaceAll will not allow this. How can I do the same thing in as below in Java?:
replaceDotHandlesWithUnderscore(input) {
// e.g. {my.nested.value} to {my_nested_value}
// e.g. {my.nested.value, select, true {Yes} false {No}} to {my_nested_value, select, true {Yes} no {false}}
return input.replace(
/\{(\s*)(\w+(\.\w+)*)/g,
(matches, space, handle) => `{${space}${handle.replace(/\./g, '_')}`
);
}
It's fine to go with Java 1.8 or 1.9 solutions to this.