{ } donates repetitions, for example (from the Java Pattern doc)...
X{n} X, exactly n times
So, the only thing you have to do is the escape that:
\{City}
But of course, inside a String, you have again to escape the backslash, so your solution is...
text = text.replaceAll("\\{City}", "New York")
Example:
final String text = "Foo {city} bar {city}."; System.out.println(text.replaceAll("\\{city}", "New York"));
Results in: Foo New York bar New York.
But honestly, I think such a question is more appropriate for StackOverflow.
Thank you for your answer. If I use your code example, the app does not replace anything. What is the reason for this?
Hard to guess. Upper and lower case? Try to play around with basic, simple examples first before you add the whole POI layer.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
{ } donates repetitions, for example (from the Java Pattern doc)...
X{n} X, exactly n times
So, the only thing you have to do is the escape that:
\{City}
But of course, inside a String, you have again to escape the backslash, so your solution is...
text = text.replaceAll("\\{City}", "New York")
Example:
final String text = "Foo {city} bar {city}.";
System.out.println(text.replaceAll("\\{city}", "New York"));
Results in: Foo New York bar New York.
But honestly, I think such a question is more appropriate for StackOverflow.
Thank you for your answer. If I use your code example, the app does not replace anything. What is the reason for this?
Hard to guess. Upper and lower case? Try to play around with basic, simple examples first before you add the whole POI layer.