如何忽略转义字符?

时间:2013-07-18 10:31:58

标签: powershell powershell-v3.0

这是我的字符串

$mystring = "INSERT INTO `glpi_networkports` (`entities_id`,`is_recursive`,`items_id`,`itemtype`,`comment`,`logical_number`,`name`,`networkinterfaces_id`,`ip`,`mac`,`netmask`,`gateway`,`subnet`,`netpoints_id`)"

我怎么能忽略逃脱?

因为它给了我这样的字符串:

INSERT INTO glpi_networkports (entities_id,is_recursive,items_id,itemtype,comment,logical_number,
ame,
etworkinterfaces_id,ip,mac,
etmask,gateway,subnet,
etpoints_id)

由于

2 个答案:

答案 0 :(得分:5)

目前您的select语句已更改,因为您使用了双引号字符串并且`n扩展为新行,将select变为无效语句。

使用单引号来维护反引号并禁用字符串扩展。

答案 1 :(得分:4)

使用quote或双倍的转义字符:

$mystring = "INSERT INTO 'glpi_networkports' ..."
$mystring = "INSERT INTO ``glpi_networkports`` ...