scala - 使用 scala fastparse 删除封闭的转义引号但保留其他引号
问题描述
我想使用fastparse将以下字符串\"Escaped quote\"\"\"
转换为Escaped quote\"
. 我有以下几乎可以工作的代码。
def escapedQuote[_: P]: P[Unit] = P("\"")
def unquotedColumn[_: P] = P(escapedQuote ~ ((!escapedQuote ~ AnyChar.!) | escapedQuote ~ escapedQuote.!).rep ~ escapedQuote ~ End)
val result = parse(input, unquotedColumn(_))
我得到的结果ArrayBuffer(E, s, c, a, p, e, d, , q, u, o, t, e, ")
非常接近我想要的结果,但是我想要一个字符串中的结果。
但是,当我尝试以下操作时(在代表之后添加 .!),
def unquotedColumn[_: P] = P(escapedQuote ~ ((!escapedQuote ~ AnyChar.!) | escapedQuote ~ escapedQuote.!).rep.! ~ escapedQuote ~ End)
我得到了结果Escaped quote\"\"
。出现了一个额外的转义引用。
我想unquotedColumn
在其他解析器中使用我的。
任何想法如何修复我的代码?
解决方案
推荐阅读
- python-3.7 - 如何在python中获取环境文件?
- c - 为什么 malloc 返回一个指针?
- spring-boot - 多个 Spring Kafka Consumer 一类 多组
- php - 以正确的方式在codeigniter中路由
- javascript - 选择要提交的特定表
- azure-active-directory - AAD - 所有者密码凭证流
- javascript - 如何使用 Jquery 在下拉菜单上更改 div css/scss?
- regex - 索引数据范围并与列进行比较,然后从同一列返回第一个可用选项
- python - 烧瓶 request.form [] 不提取数据
- javascript - 使用实时 API 数据的 React-table 加载速度比使用模拟数据慢