I have a list of key value pairs which I want to use to replace values inside a String.
I don't know what the keys/values will be so it must remain dynamic which makes using Regex a little hard.
The code I currently have, does exactly what I want but I'm thinking there has to be a cleaner more functional style of handling this?
private String replaceStringValues(final List<Sanitize> sanitizeList, final String value) {
String sanitizedValue = "";
for (final Sanitize sanitize : sanitizeList) {
sanitizedValue = value.replace(sanitize.key(), sanitize.value());
}
return sanitizedValue;
}
Any help?