Solution not using regex:
String input = "Hello #'World'# , currently i am in #'world's'# best location.";
StringBuilder buf = new StringBuilder(input.length());
int start = 0, idx1, idx2;
while ((idx1 = input.indexOf("#'", start)) != -1) {
idx1 += 2;
if ((idx2 = input.indexOf("'#", idx1)) == -1)
break;
buf.append(input, start, idx1); // append text up to and incl. "#'"
for (; idx1 < idx2; idx1++)
buf.append('@'); // append replacement characters
start = idx2 + 2;
buf.append(input, idx2, start); // append "'#"
}
buf.append(input, start, input.length()); // append text after last "'#"
String output = buf.toString();
System.out.println(input);
System.out.println(output);
Output
Hello #'World'# , currently i am in #'world's'# best location.
Hello #'@@@@@'# , currently i am in #'@@@@@@@'# best location.