Removing First and Last Double Quotes
If the "
characters are always going to be the first and last ones, you don't need a regex. Just use substring
:
x = x.substring(1, x.length() - 1)
try this regex
s = s.replaceAll("\"(.+)\"", "$1");
Try this code:
public class Example {
public static void main(String[] args) {
String x = "\"‘Gravity’ tops the box office for 3rd week | New York Post\"";
String string = x.replaceAll("^\"|\"$", "");
System.out.println(string);
}
}
it gives:
‘Gravity’ tops the box office for 3rd week | New York Post