Hello everyone I want to ask about memory utilization and time required for a process. I have these following code. I want to optimize my code so that it will be faster. String will take more memory any alternative for that?
public String replaceSingleToWord(String strFileText) {
strFileText = strFileText.replaceAll("\\b(\\d+)[ ]?'[ ]?(\\d+)\"", "$1 feet $2 ");
strFileText = strFileText.replaceAll("\\b(\\d+)[ ]?'[ ]?(\\d+)''", "$1 feet $2 inch");
//for 23o34'
strFileText = strFileText.replaceAll("(\\d+)[ ]?(degree)+[ ]?(\\d+)'", "$1 degree $3 second");
strFileText = strFileText.replaceAll("(\\d+((,|.)\\d+)?)sq", " $1 sq");
strFileText = strFileText.replaceAll("(?i)(sq. Km.)", " sqkm");
strFileText = strFileText.replaceAll("(?i)(sq.[ ]?k.m.)", " sqkm");
strFileText = strFileText.replaceAll("(?i)\\s(lb.)", " pound");
//for pound
strFileText = strFileText.replaceAll("(?i)\\s(am|is|are|was|were)\\s?:", "$1 ");
return strFileText;
}
I think it will take more memory and time I just want to reduce the complexity.I just want reduce time and memory for process what changes i need to do.is there any alternative for replaceAll function? How this code i will minimize? so that my get faster and with low memory utilization? Thank you in advanced