I have set of String
s where the first and last characters are double quotes. Below is an example.
String x = "‘Gravity’ tops the box office for 3rd week | New York Post"
Some other strings will contain double quotes in the middle of the text, so I can't use String.replaceAll()
. I just need to remove the first and last double quotes. How can I do this?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With