how to escape quotes in gremlin queries

*爱你&永不变心* 提交于 2019-12-01 03:19:11

问题


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)

Any Ideas how to escape it?


回答1:


Escape the apostrophe using \

So your Gremlin becomes:

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



回答2:


Found out the answer

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

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

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

and the same function above for decoding



来源:https://stackoverflow.com/questions/44483185/how-to-escape-quotes-in-gremlin-queries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!