I need to replace <keyword> with a string.
String result = "<keyword>".replace(Pattern.quote("<keyword>"), "text");
Expected result: text
Got result: <keyword>
Any ideas?
As String.replace doesn't use regex parameters you can just use
String result = "<keyword>".replace("<keyword>", "text");
It seems that you want to use replaceAll which uses a regex instead of replace that doesn't.
String result = "<keyword>".replaceAll("<keyword>", "text");
If you check the replaceAll javadocs you will find:
String result = "<keyword>".replace("<keyword>", "text");