Re: How do I do a LOT of non-regular-
Stryder wrote:
Here's what I settled on. Thanks for all the help! The CharSequences
Please do not top-post.
sped things up the most, and using an Entry set helped also. I'm now
just a tiny bit less of a newbie 8^)
static String unescapeString(String inputString) {
Set<Map.Entry<CharSequence, CharSequence>> set =
entitiesHashMap.entrySet();
for (Map.Entry<CharSequence, CharSequence> me : set) {
It's slightly more compact just to put the 'entrySet()' call after the colon
in lieu of declaring a separate variable for it, but it does no harm to
declare the variable.
inputString = inputString.replace(me.getKey(), me.getValue
());
}
return inputString;
}
This approach creates a lot of intermediate String objects. If you use a
StringBuilder you can avoid the intermediate objects at the expense of rather
more complex code.
Unless String objects represented a huge burden, I would usually prefer the
way you did it.
--
Lew