My input is
<option value="" disabled selected hidden>
The output should be something like this:
<option value="" disabled="disabled" selected="selected" hidden="">
Then I tried this code;
final String REGEX_DISABLED = "(?<=option value=\"\" disabled)(?=.*)";
final String REPLACE_DISABLED = "=\"disabled\"";
Pattern disP = Pattern.compile(REGEX_DISABLED);
Matcher disM = disP.matcher(text);
text = disM.replaceAll(REPLACE_DISABLED);
final String REGEX_SELECTED = "(?<==\"disabled\" selected)(?=.*)";
final String REPLACE_SELECTED = "=\"selected\"";
Pattern selP = Pattern.compile(REGEX_SELECTED);
Matcher selM = selP.matcher(text);
text = selM.replaceAll(REPLACE_SELECTED);
final String REGEX_HIDDEN = "(?<==\"selected\" hidden)(?=.*)";
final String REPLACE_HIDDEN = "=“”";
Pattern hidP = Pattern.compile(REGEX_HIDDEN);
Matcher hidM = hidP.matcher(text);
text = hidM.replaceAll(REPLACE_HIDDEN);
It actually worked but since I was asked to do it more simple, I was hoping if I could find something really useful and more simple since I tried to apply other ways but it won't work and tried searching for some other ways.