I've been looking all night but none of the other answers satify my needs. They don't even run http://regexr.com/ . What i'm looking is to replace all between <whatever> replace this stuff </whatever>
public void updateValue(String tag, String value) {
content = content.replaceAll("<"+tag+">(.?+)</"+tag+">", value);
}
public void updateValue(String tag, int value) {
content = content.replaceAll("<"+tag+">(.?+)</"+tag+">", value+"");
}
public void updateValue(String tag, File value) {
content = content.replaceAll("(&<"+tag+">=)[^&]*(&</"+tag+">=)", value.getPath());
}
None of them work at all.
EDIT
Current approach, tags are beign removed along with it's content by regex.
private void replaceValue(String tag, String value) {
content = content.replaceAll("<"+tag+">(.*?)<\\/"+tag+">", "<"+tag+">"+value+"</"+tag+">");
}
.?+is incorrect syntax as that site tells you. What are your needs anyway?