问题标签 [quoting]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
9840 浏览

python - Python -c 开关

我目前有

哪个有效,但是当我尝试通过 python -c 开关使用它时它失败了?

有任何想法吗 ?

0 投票
5 回答
4916 浏览

string - 将字符串转换为参数时,Bash 不解析引号

这是我的问题。在 bash 3 中:

如何让 bash 理解引号并将 $2 作为This is two而不是返回"This?不幸的是,我无法更改test此示例中调用的变量的构造。

0 投票
2 回答
295 浏览

sql - Issue with quoting of IS, NULL, NOT, !, and other reserved strings in ON conditions of JOIN clauses in Zend Framework 2

I have an SQL statement, that selets sport classes/courses (courses) with their trainers (trainers) over an association table (courses_trainers). Since some courses have multiple trainers, I use the GROUP_CONCAT(...) function to get the trainer names into one field. Some trainers rows are empty or NULL, so I add a trainers.name IS NOT NULL and a trainers.name != "" condition to the ON clause of the trainers JOIN:

SQL statement

OO variant in the CourseTable class

The generated JOIN code I get looks like this:

So, here is to much quoted.

How to "explain" to the ZF, that IS, NOT, " etc. should not be quoted?

0 投票
2 回答
2154 浏览

java - Java Regex:看后面组没有“明显的最大长度”

我有一个正在运行的服务,它使用发送给它的正则表达式并使用它从字符串中检索一个值。

我可以在类中创建一个主要方法并调试正则表达式(?<=\\().+?(?=\\){1}),它工作得很好。

但是,一旦我将其部署到 tomcat 中进行远程测试,就会出现以下异常:

这是用于解析正在调用的值的函数:

发生了什么导致它在应用程序中编译,但在 web 应用程序中不起作用?

编辑:

使用任何字符串都会失败,但当前检查的字符串是:“(Group Camp Renovation)”

当从 调用时main,该方法返回“Group Camp Renovation”,当通过 webapp 调用时,它会抛出异常。

0 投票
1 回答
10472 浏览

python - 使用 Python 将包含双引号的参数传递给子进程

我正在寻找一种将包含双引号的参数传递给python的子进程模块的方法,而不会转义双引号。

当引号围绕 arg 时,我已经看到这个问题被问了几次,但答案通常是删除引号。我遇到的问题是引号是参数的一部分,必须传递给脚本,而不是在每个引号前面加上反斜杠

例子:

我正在调用 subprocesTest.bat,这是一个简单的批处理脚本,它接受一个参数并回显它:

我使用包含引号的 arg 从 python 调用批处理脚本:

预期输出:

“比尔说“嗨!”

实际输出:

“比尔说“嗨!”

从命令行调用相同的批处理脚本时,我可以获得预期的输出,如下所示:

subprocesTest.bat "比尔说“嗨!”"

查看源代码,subprocess.py 的 list2cmdline 函数记录如下:

但是,如果我单步执行此函数,我看不到在不添加反斜杠的情况下传递双引号的方法:

所以我有两个问题...

  • 是否可以将 arg 传递给包含双引号但不加反斜杠的子进程
  • 如果不可能,有人可以向我解释为什么该功能是这样设计的吗?函数文档字符串中的第 3 项似乎表明我可以通过在反斜杠前面添加文字引号,但这不会产生我正在寻找的行为。我读错了文档吗?

以下是提出此问题的其他线程,并且通过不使用引号来解决:

对于我实际上想在我的论点中传递引号的情况,我没有看到任何回应

0 投票
2 回答
8290 浏览

php - PDO::prepare() 不转义 SQL 中的特殊字符

HTML textarea我有来自无法插入 MySQL 表的元素的输入值,因为它包含撇号(')字符,例如: 'Adam's garden'。因此,我按照 PHP 文档的建议使用了 PDO::prepare() 函数,但我仍然无法将此数据插入表中,但是当我删除撇号时'Adams garden',该值已成功插入

我认为该PDO::prepare()函数应该处理 SQL 语句的引号和转义特殊字符。PHP 文档确实说要PDO::prepare()与绑定参数一起使用,但我没有将我的 php 变量绑定到查询参数。绑定参数是绝对必要的还是只是因为这是使用PDO::prepare()函数的常用方式而被声明?

我如何在输入变量中引用和转义特殊字符?

编辑: 我正在使用字符串连接来执行多个 SQL INSERT。撇号位于$evData['Description']以下示例代码的字段中。

这是 PHP 文档部分:

PDO::quote() 在输入字符串周围放置引号(如果需要)并转义输入字符串中的特殊 > 字符,使用适合底层 > 驱动程序的引用样式。

如果您使用此函数构建 SQL 语句,强烈建议您使用 PDO::prepare() 来准备带有绑定参数的 SQL 语句,而不是使用 PDO::quote() 将用户输入插入到 SQL 语句中。带有绑定参数的预处理语句不仅更便携、更方便、不受 SQL 注入的影响,而且执行起来通常比插值查询快得多,因为服务器端和客户端都可以缓存查询的编译形式。 http://www.php.net/manual/en/pdo.quote.php

0 投票
3 回答
103 浏览

bash - How to let empty arguments survive in command substitutions?

I want to call dialog à la:

except A, B and C are the result of a dynamic query, for the sake of this question the latter being { echo A; echo B; echo C; }.

I can get the desired command line seemingly by:

but:

and its output:

show that the result of the command substitution is only word-split, but '' isn't interpreted as an empty argument, but passed verbosely to echo (and thus, dialog wouldn't display no descriptions for the menu items, but literally ''s).

I can work around this in bash using arrays, but is there a simpler solution I'm missing?

Given

How can I change the $(...) part, such that the item is [] instead of [''].

0 投票
2 回答
201 浏览

bash - retaining quotes in bash correctly

I am trying to pass arguments from a bash script to an executable and one of them contains spaces. I have been searching how to solve this, but I cannot find the right way to do it. Minimal example with a script called first and a script called second.

first script:

second script:

Now if I run it like this, I get the following results:

How can I make it so, that the second script also only receives one argument?

0 投票
2 回答
487 浏览

bash - bash 脚本 tr -d [:punct:] 不起作用

该命令在我的笔记本电脑上无法正常工作,因为它不会删除标点符号。

但是从字符串tr -d [:punct:]中删除。t

0 投票
3 回答
221 浏览

bash - 在 Bash 变量中保留解释

我正在尝试在 Bash 变量中保留解释。

例子

当我在命令提示符下运行以下行时。

我得到以下(这是我想要的):

如果我将错误处理代码放在一个变量中,它就会爆炸。

我试过引用很多方法,但没有运气。我似乎无法保留2>>对变量部分的解释。