PeakGen PeakGen - 2 years ago 104
Java Question

Removing First and Last Double Quotes

I have set of

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
. I just need to remove the first and last double quotes. How can I do this?

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download