using dictionaries (TreeMap) and replaceAll regex