javajavacc

How do you remove double quotes from the image of a JavaCC token?


In JavaCC, I'm accepting strings that are under the condition:

   < STRING : "\"" ("\\" ~[] | ~["\"","\\"] )* "\"" > 

So the image ends up printing anything that is a string but with another set of double quotes.

For example, I'll input: "This is a sentence."

And the value will result : ""This is a sentence."" stored in a String variable.

Is there a way in Java to remove the extra set of double quotes so that it only prints: "This is a sentence."?


Solution

  • str = str.substring(1,str.length()-1)
    

    alternate for Javacc

    Parsing Strings with JavaCC