I have a set of regex replacements that are needed to be applied to a set of String,
For example:
- all multiple spaces with single space
("\s{2,}" --> " ")
- all . followed by a char with . followed by space followed by the char
(\.([a-zA-Z]-->". $1")
So I will have something like this:
String s="hello .how are you?";
s=s.replaceAll("\\s{2,}"," ");
s=s.replaceAll("\\.([a-zA-Z])",". $1");
....
it works , however imagine I'm trying to replace 100+ such expressions on a long String. needless to say how slow this can be.
so my question is if there is a more efficient way to generalize these replacements with a single replaceAll (or something similar e.g. Pattern/Matcher)
I have followed Java Replacing multiple different...,
but the problem is that my regex(s) are not simple Strings
.