Question

I was wondering if there is an easy way I'm unaware of at the moment to remove " characters from the beginning and end of a stringLiteral captured by a TokenParser?

I searched through the Scaladocs but haven't found a handy util function for it. Yeah, I can surely do it by playing with substring(1, str.length - 1) but my gut feeling is that it is already written somewhere I'm just cannot find it :-)

Thanks in advance!

Was it helpful?

Solution

If you want to use stringLiteral from JavaTokenParsers you could create your own parser based on it:

def deguoted: Parser[String] = stringLiteral ^^ {str => str.substring(1, str.length - 1)}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top