I want to use fastparse to transform the following string \"Escaped quote\"\"\"
into Escaped quote\"
. I have the following code which almost works.
def escapedQuote[_: P]: P[Unit] = P("\"")
def unquotedColumn[_: P] = P(escapedQuote ~ ((!escapedQuote ~ AnyChar.!) | escapedQuote ~ escapedQuote.!).rep ~ escapedQuote ~ End)
val result = parse(input, unquotedColumn(_))
I get the result ArrayBuffer(E, s, c, a, p, e, d, , q, u, o, t, e, ")
which is very close to what I want, however I want the result in a String.
However, when I try the following (adding .! after the rep),
def unquotedColumn[_: P] = P(escapedQuote ~ ((!escapedQuote ~ AnyChar.!) | escapedQuote ~ escapedQuote.!).rep.! ~ escapedQuote ~ End)
I get the result Escaped quote\"\"
. An extra escaped quote has appeared.
I want to use my unquotedColumn
in other parsers.
Any ideas how to fix my code?