String.replaceAll variant that handles each match using closure