Preventing stack overflow?
Is there a way to replace an old variable value with a new one? I'm using a really long string and using a loop to replace all instances of some pattern. There are a lot of these find and replace loops, which is why there is a stack overflow error.
Example of one:
Is there a way to clear the content value before adding the new edited string, or would multiple variables be better - like for the other patterns, create new strings called content2, content3, etc (or arrays)?
String content = /*some long string*/;
Pattern nbspPattern = Pattern.compile("(?i) ");
Matcher nbspMatcher = nbspPattern.matcher(content);
content = content.replaceAll("(?i) "," ");
I'm open to any other suggestions as well, such as alternatives or more efficient ways of accomplishing the above.