This is the regex which is used to find block comments and it works absolutely fine
/\\*(?>(?:(?>[^*]+)|\\*(?!/))*)\\*/
I just need to modify it a little bit. Find a semi-colon (;) that "may" exists in the block comments and replace it with a white space.
Currently I am doing this
while (m.find()) {
if (m.group().contains(";")) {
replacement = m.group().replaceAll(";", "");
m.appendReplacement(sb, replacement);
}
}
m.appendTail(sb);
But I need to replace it with a str.replaceAll kind of statement. In short anything that is more efficient because I get out of memory exception. I fixed a few other regex that used to throw same exception and they are working fine. I hope this regex can also be optimized.
--- Edit ---
These are the string you can test this regex on
/* this* is a ;*comment ; */
/* This ; is*
another
;*block
comment;
;*/
Thanks