I would like to change a word in a sentence, but the word has parenthesis. I keep it in the String variable. Inside of the variable st I have
man
I believe you wanted to use String#replace() (not replaceAll
), this
String EDC = "query(MT0, P0) :- not(manages(P0,MT0)), "
+ "ins_manages(P0,MT0), not(physician(P0)), not(ins_physician(P0))";
String queryPart = "managesa";
EDC = EDC.replace("manages(P0,MT0)", queryPart);
System.out.println(EDC);
Output is
query(MT0, P0) :- not(managesa), ins_managesa, not(physician(P0)), not(ins_physician(P0))