如何在gremlin查询中转义报价 [英] how to escape quotes in gremlin queries

查看:107
本文介绍了如何在gremlin查询中转义报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此查询,当您的名字包含单引号Anthony O'Neil

I have this query and as you firstName contains single quote Anthony O'Neil

:> g.addV('person')
    .property('firstName', 'Anthony O'Neil')
    .property('lastName', 'Andersen')
    .property('age', 44)

任何想法如何逃脱它?

推荐答案

找出答案

用于编码使用此: encodeURIComponent("Anthony O'Neil").replace(/[!'()*]/g,转义) 输出为:Anthony%20O%27Neil

for encoding use this: encodeURIComponent("Anthony O'Neil").replace(/[!'()*]/g, escape) and the output is: Anthony%20O%27Neil

用于解码,请使用以下命令: encodeURIComponent("Anthony%20O%27Neil") 然后您会回来Anthony O'Neil

for decoding use this: decodeURIComponent("Anthony%20O%27Neil") and you will get back Anthony O'Neil

如果您只想转义单引号,请使用此代码进行编码: "Anthony O'Neill" .replace(/[!'()*]/g,转义) 输出:Anthony O%27Neill

if you just want to escape the single quote use this for encoding: "Anthony O'Neill".replace(/[!'()*]/g, escape) output: Anthony O%27Neill

与上面相同的解码功能

这篇关于如何在gremlin查询中转义报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆