简体   繁体   English

如何在Node.js中转义双引号

[英]How to escape double quotes in Node.js

I have tried / to escape the double quotes in a string but i am not able to get the desired string. 我已经尝试过/来对字符串中的双引号进行转义,但是我无法获得所需的字符串。

The code snippets are as follows in Node.js 代码片段在Node.js中如下

var queryString = "select * from courier where couriername LIKE '%"+filterName+"%'";
console.log(querystring);

The output i am getting is like with double quotes included on console: 我得到的输出就像控制台上包含双引号一样:

select * from courier where couriername LIKE '%"a"%'

But I want output like this 但是我想要这样的输出

 select * from courier where couriername LIKE '%a%';

How to get this .. I have tried many things ... 如何获得..我尝试了很多事情...

Seems to me that filterName is equal to "a" and not a 在我看来filterName等于“ a”而不是a

Can you log its value ? 您可以记录其价值吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM