Questions tagged [single-quotes]
Questions related to the use of single-quotes in different programming languages.
362
questions
1378
votes
15
answers
1.8m
views
How do I escape a single quote in SQL Server?
I am trying to insert some text data into a table in SQL Server 9.
The text includes a single quote '.
How do I escape that?
I tried using two single quotes, but it threw me some errors.
eg. insert ...
904
votes
7
answers
436k
views
What are the differences between single and double quotes in Bash?
In Bash, what are the differences between single quotes ('') and double quotes ("")?
447
votes
12
answers
438k
views
Usage of the backtick character (`) in JavaScript
In JavaScript, a backtick† seems to work the same as a single quote. For instance, I can use a backtick to define a string like this:
var s = `abc`;
Is there a way in which the behavior of ...
241
votes
8
answers
196k
views
Escape single quote character for use in an SQLite query
I wrote the database schema (only one table so far), and the INSERT statements for that table in one file. Then I created the database as follows:
$ sqlite3 newdatabase.db
SQLite version 3.4.0
Enter &...
220
votes
7
answers
87k
views
Double vs single quotes
Is there a specific time when I should use "" vs ''?
I've been using single quotes most of the time because it's easier to type but I'm not sure if I should.
e.g. get 'user/new' vs. get &...
104
votes
3
answers
32k
views
How does the leading dollar sign affect single quotes in Bash?
I need to pass a string to a program as its argument from the Bash CLI, e.g
program "don't do this"
The string may include any character like '$', '\', etc. and I don't want Bash to do any ...
46
votes
3
answers
26k
views
Are double "" and single '' quotes (always) interchangeable in R?
This is perhaps rather a minor question...
but just a moment ago I was looking through some code I had written and noticed that I tend to just use ="something" and ='something_else' completely ...
35
votes
7
answers
255k
views
How to Insert Double or Single Quotes
I have a long list of names that I need to have quotes around (it can be double or single quotes) and I have about 8,000 of them. I have them in Excel without any quotes and I can copy all of the ...
20
votes
1
answer
16k
views
Single quote in JSON field POSTGRESQL
I am trying to manipulate a JSON with a single quote inside, and I am having some troubles:
1.- When I have a function, I cant pass as parameter a JSON string with a single quote inside:
This is the ...
19
votes
1
answer
4k
views
Should I use single or double quotes in my .vimrc file?
What’s the difference between single (') and double (") quotes in Vim? Does it make speed differences? Is it better to use one or another when running functions inside it? Does it matter at all?
I’m ...
15
votes
1
answer
3k
views
Stopping Pandoc from escaping single quotes when converting from HTML to Markdown
If I convert a single quote ' from HTML to Markdown, it is automatically escaped:
% echo "'" | pandoc -f html -t markdown
\'
I'd like it to output without the slash, as it makes text with ...
13
votes
4
answers
16k
views
How can I accommodate a string with both single and double quotes inside of it in JavaScript
I have an application, and it is fed some HTML. It then needs to put that HTML into a string. This HTML contains single and double quotes. Is it possible, in javascript, to declare a string with ...
11
votes
6
answers
25k
views
Add single quotes to a string
I try to add single quotes to a string but don't see how to do it. For instance I would like to replace ABC by 'ABC'.
I have played with paste, cat, print but don't see how to do it.
Any solution?
...
11
votes
6
answers
48k
views
Escaping single quotes in REDSHIFT SQL
I've lots of string values containing single quotes which I need to insert to a column in REDSHIFT table.
I used both /' and '' to escape the single quote in INSERT statement.
e.g.
INSERT INTO ...
11
votes
5
answers
42k
views
Python how convert single quotes to double quotes to format as json string [duplicate]
I have a file where on each line I have text like this (representing cast of a film):
[{'cast_id': 23, 'character': "Roger 'Verbal' Kint", 'credit_id': '52fe4260c3a36847f8019af7', 'gender': 2, 'id': ...
7
votes
3
answers
3k
views
RubyMine: key press to "convert to single quoted"?
Is there a keyboard shortcut to toggle between single quotes and double quotes in a Ruby code? Or a key I can set up to accept the Inspection Hint?
Thanks, M.
7
votes
4
answers
10k
views
Vue: Failed to compile (Strings must use singlequote)
I've been working with Visual Studio Code for two days now. I try to build a Vue-Application. But always when I run the application by npm run serve, I get the following errors:
9:9 error ...
7
votes
3
answers
48k
views
Adding single quotes to a cell using VBA
I am trying to add single quotes to values in a column by using Chr(39), but I am only getting the second quote.
e.g. I want 'value' but I am getting value'
But if I use double quotes by using Chr(34) ...
7
votes
1
answer
819
views
Ruby on Rails, convert projectwide single quotes to double quotes
I wonder if anyone has come up with a shortcut to correctly convert ALL single quotes to double quotes in a new rails project. Thank you in advance. I would do that at the end of generating new ...
6
votes
1
answer
3k
views
Don't escape single quotes with System.Text.Json
I would like .net core System.Text.Json to ignore the single quote character when escaping characters for serialization but I just can't get it to work:
var encoderSettings = new TextEncoderSettings();...
6
votes
1
answer
4k
views
Spring message tag has troubles with the single quote character
I have 3 properties defined in my resource bundle:
test.key1 = Just a normal snippet.
test.key2 = snippet with {0} arguments {1}.
test.key3 = snippet with 'charac'ter'.
test.key4 = snippet with {0} ...
6
votes
2
answers
232
views
Performance: " or ' PHP [duplicate]
I'm working on a big project in php and I need to make sure it's all fast. So I'm wondering: what is faster to use, " or ' ? (Eg: $_SESSION['example'] or $_SESSION["example"])
6
votes
1
answer
4k
views
Autochange Setting Double Quotes to Single Quotes in VSCode
i explored all over the topics and found out there is no answer for this question,
everyone is using search and replace, that's not the point.
we have to set the default value for attributes when ...
6
votes
1
answer
3k
views
In R, why do style guides recommend that one only use double quotes?
The lintr package has a check for single-quoted strings, and single quotes are discouraged elsewhere (e.g. ?Quotes). Single and double quoted strings work identically in R, so is there a reason why ...
5
votes
5
answers
2k
views
Why does single quote in Lisp always return upper case?
I'd like to be able to set case from a single quote, but that does not seem possible.
(format nil "The value is: ~a" 'foo)
"The value is: FOO"
(format nil "The value is: ~a" 'FOO)
"The value is: FOO"...
5
votes
1
answer
510
views
Single quotes in a variable name in Perl?
I was writing some Perl code in vim and accidentally typed a single quote character in a variable name and noticed that it highlighted it in a different color than normal single quoted strings.
I ...
5
votes
0
answers
1k
views
How to ignore quotes from being formatted by Prettier
I have a code base with both single and double quotes all over the place. When I format my TS files all the single quotes are being converted to double quotes. I want prettier to ignore considering ...
4
votes
4
answers
532
views
The difference between " and ' in Perl
According to this comment:
You also should not use single quotes in print ">>${ '_<$filename' }<<\n".
Instead try: print ">>${ \"_<$filename\" }<<\n"
I always ...
4
votes
3
answers
5k
views
Python Replace Single Quotes Except Apostrophes
I am performing the following operations on lists of words. I read lines in from a Project Gutenberg text file, split each line on spaces, perform general punctuation substitution, and then print each ...
4
votes
3
answers
2k
views
How to select an element that contains quote marks?
How can I use querySelector or any other Javascript selector when the element's attribute contains quote marks " ?
For example, if I search for an img element that has a src of http://www.example.com/...
4
votes
3
answers
2k
views
wrapping commands through ssh: how to manage complex quotes?
I use an HPC cluster. The compute nodes can't have access to internet, only the frontal.
So I want to wrap all the commands that need to access internet in order to execute them on the frontal.
ex: ...
4
votes
1
answer
3k
views
powershell: newline in a single-quoted string?
In powershell, double-quotes " indicate an "expandable" string, akin to "string interpolation" in other contexts. Single-quotes ' are strings which do not undergo ...
4
votes
1
answer
5k
views
PHP: Convert single-quoted string into double-quoted
I need to convert string with unicode \xCODEs into regular string.
The issue is that string which I have as input seems to be single-quoted.
Is there any way to convert single-quoted string into ...
4
votes
1
answer
20k
views
Ansible escaping double quotes and single quotes
I would like insert a nrpe command in the nrpe.cfg with this ansible command
check_tomcat_threads.pl -H localhost -p 30011 -C '"http-bio-30011"' -w 200 -c 50
But the the problem are the '" and "'
...
4
votes
2
answers
938
views
Bash script with a command with lots of single and double quotes
I need to use the curl command:
curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://localhost:3030/widgets/welcome
in a bash script but instead of "Hey, Look ...
3
votes
4
answers
9k
views
Making a new line with single quotes?
Can I do a line break like this '\n'?
Or do I must use double quotes - "\n"?
3
votes
5
answers
3k
views
Unable to replace string in Swift
Trying to escape few special characters of string for sending it via xml api.
Tried below code but not working for all the occurrences of Single Quote (') and Double Quote (")
var strToReturn = "“...
3
votes
1
answer
1k
views
C - single quotes vs double quotes
I'm curious about this code:
int a = 'ftyp'; // a == 1718909296
int b = *((int*)"ftyp"); // b == 1887007846
My question: Why a != b ?
3
votes
2
answers
2k
views
Powershell variable expansion in single quoted string
I need to build a JSON variable that contains another JSON formatted content which should be formatted as a string. I'm putting the inner JSON into single quote so it wont get parsed along with the ...
3
votes
3
answers
284
views
Negate Single Quote In Character Class
I have the following code where I am trying to replace assign with always @(*) using SED.
Essentially I am trying to ignore the ' in character class but SED still seems to match it. I don't want sed ...
3
votes
2
answers
328
views
Coping with apostrophe (single quote) in username with powershell command - Get-Azureaduser
I'm cycling through a list of users and need to call get-azureaduser with each one.
The email address is stored in a variable $email and my command looks like this:
$user = Get-AzureAdUser -filter &...
3
votes
2
answers
488
views
Printing in both double and single quotes
I am on exercise 8 of Learning Python the Hard Way, and I don't understand why certain lines in a print function are printed in single or double quotes.
The program reads as follows:
formatter = "%r ...
3
votes
2
answers
4k
views
ColdFusion single quote issue with SQL Query
In my ColdFusion 11 app, with SQL Server 2008-R2, I've following cfquery tag inside a CF Component:
<cfquery name="result_set" dataSource="#request.dsn_name#">
select ...
2
votes
2
answers
377
views
Why does q/\\a/ equal q/\a/?
The following example prints "SAME":
if (q/\\a/ eq q/\a/) {
print "SAME\n";
}
else {
print "DIFFERENT\n";
}
I understand this is consistent with the documentation. But I think this behavior ...
2
votes
4
answers
656
views
Parse variables out of a "key1='val1' key2='val2'" string in bash without eval
I have one project specific command which produces output in the below form:
Parameter1='value1' Parameter2='Value2' ... #Single quoted value for
the variable.
But I wanted to explicitly assign the ...
2
votes
4
answers
2k
views
In R, print vector in single quotes and comma separated
Problem Statement: I'm creating a dynamic application in which user select inputs and they are passed into URL to filter data. User can select single or multiple values. I'm using knitr::combine_words(...
2
votes
3
answers
1k
views
Is it possible to replace these single quotes with double quotes?
I'm having some trouble trying to replace the single quotes ('...') with double quotes("...") in the following piece of code:
<img id="image" src="images/bird.jpg" onmouseover="PlaySound('mySound'...
2
votes
3
answers
3k
views
Python regex to match quoted string with escaped single quotes
I was using this pattern to match single quoted strings in parser:
"'.+?'"
But I need regex that can find single quoted string with postgres like escape of single qoutes (doubling single qoutes). ...
2
votes
2
answers
1k
views
Why are single quotes more commonly used in JS files in the last couple of years? [closed]
Why is there a trend for people to use single quotes ' around string instead of double quotes " when writing javascript? Are there any minifcation or linting tools that follow the java / c / c++ ...
2
votes
2
answers
179
views
quotes in bash when submitting r cmd batch commands
Problems with single quotes in a bash script
I have seen this post but my problem is more complicated and simply replacing single quotes with double quotes won't work. I need to run a R CMD BATCH ...