Well I have this code:
String replacedItemName = ItemDefinitions.getItemDefinitions(usedWith).getName().replaceAll("\\(.\\)", "(6)");
Is \\(.\\)
the correct regex to replace anyting in the brackets of the item name? (Java)
Well I have this code:
String replacedItemName = ItemDefinitions.getItemDefinitions(usedWith).getName().replaceAll("\\(.\\)", "(6)");
Is \\(.\\)
the correct regex to replace anyting in the brackets of the item name? (Java)
I would suggest to use replaceAll("(?<=\\().*?(?=\\))", "6");
. See here
Almost, you forgot a plus (one-or-more) after your dot. Without the plus, the dot only matches one character.
\(.+\)
However, I am unsure what strings you are targeting. I've made a Rubular with some examples:
http://rubular.com/r/0WijBsdtV0
Do these match your intended behavior?