The regular expression I am trying to use is
String re2="((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3}))[-:\\/.](?:[0]?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])"; // YYYYMMDD 1
But when I try to replace all occurrences,
string.replaceAll(re2,getDate(dayForward,dateFormat));
doesn’t work. And,
matcher.appendReplacement(stringBuffer, getDate(dayForward,dateFormat));
only replaces the first occurrence.
Is there any way I can replace all the occurrences?
You have to put the result in an other variable:
Otherwise, it means your regex is not right.