Questions tagged [quotes]

Computer programming languages' facility for embedding text in source code, also known as String literals

In plain English: String literals can be enclosed in matching single quotes (') or double quotes (").

References:

2134 questions
235
votes
7 answers

How to escape double quotes in a title attribute

I am trying to use a string that contains double quotes in the title attribute of an anchor. So far I tried these: Some text and
harpax
  • 5,986
  • 5
  • 35
  • 49
219
votes
7 answers

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 "user/new"
imjp
  • 6,495
  • 10
  • 48
  • 58
199
votes
5 answers

Why shouldn't `'` be used to escape single quotes?

As stated in, When did single quotes in HTML become so popular? and Jquery embedded quote in attribute, the Wikipedia entry on HTML says the following: The single-quote character ('), when used to quote an attribute value, must also be escaped as…
brad
  • 73,826
  • 21
  • 73
  • 85
178
votes
2 answers

Who wrote this programing saying? "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. I found this at somebody's blog, and it introduces as Rick Osborne's. But I google this, and other people says: Martin…
beatak
  • 9,185
  • 10
  • 33
  • 42
158
votes
17 answers

Regex for quoted string with escaping quotes

How do I get the substring " It's big \"problem " using a regular expression? s = ' function(){ return " It\'s big \"problem "; }';
Andrii Kasian
156
votes
6 answers

How to use an environment variable inside a quoted string in Bash

I've tried various forms of the following in a bash script: #!/bin/bash svn diff $@ --diff-cmd /usr/bin/diff -x "-y -w -p -W $COLUMNS" But I can't get the syntax to correctly expand the COLUMNS environment variable. I've tried various forms of the…
Jamie
  • 7,075
  • 12
  • 56
  • 86
154
votes
6 answers

Difference between single quotes and double quotes in Javascript

I know that in PHP, the only difference between double quotes and single quotes is the interpretation of variable inside a string and the treatment of escape characters. In JavaScript, I often see double quotes used in strings. Is there a particular…
Michael Lumbroso
  • 4,931
  • 5
  • 27
  • 34
154
votes
12 answers

Removing double quotes from variables in batch file creates problems with CMD environment

Can anybody help with effective and safe way of removing quotes from batch variables? I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variables. Some of these parameters contain…
BobB
  • 1,587
  • 2
  • 11
  • 7
146
votes
2 answers

What are '$$' used for in PL/pgSQL

Being completely new to PL/pgSQL , what is the meaning of double dollar signs in this function: CREATE OR REPLACE FUNCTION check_phone_number(text) RETURNS boolean AS $$ BEGIN IF NOT $1 ~ e'^\\+\\d{3}\\ \\d{3} \\d{3} \\d{3}$' THEN RAISE…
vector
  • 7,334
  • 8
  • 52
  • 80
141
votes
10 answers

How to enter quotes in a Java string?

I want to initialize a String in Java, but that string needs to include quotes; for example: "ROM". I tried doing: String value = " "ROM" "; but that doesn't work. How can I include "s within a string?
jimmy
  • 8,121
  • 11
  • 36
  • 40
136
votes
11 answers

I get "dquote>" as a result of executing a program in linux shell

When I execute a script in a Linux shell, I get this output: dquote> What does this mean?
Leonardo
  • 1,501
  • 2
  • 9
  • 6
132
votes
14 answers

How can I keep quotes in Bash arguments?

I have a Bash script where I want to keep quotes in the arguments passed. Example: ./test.sh this is "some test" Then I want to use those arguments, and reuse them, including quotes and quotes around the whole argument list. I tried using \"$@\",…
zlack
  • 1,937
  • 4
  • 15
  • 15
124
votes
19 answers

How to escape single quotes in MySQL

How do I insert a value in MySQL that consist of single or double quotes. i.e This is Ashok's Pen. The single quote will create problems. There might be other escape characters. How do you insert the data properly?
Ashok Gupta
  • 2,247
  • 5
  • 28
  • 34
122
votes
4 answers

bash alias command with both single and double quotes

I have the following command: svn status | awk '$1 =="M"{print $2;}' How do I make an alias out of it? I have tried: alias xx="svn status | awk '$1 ==\"M\"{print $2;}'"
pragmatic_programmer
  • 3,566
  • 3
  • 29
  • 36
113
votes
6 answers

Escaping Double Quotes in Batch Script

How would I go about replacing all of the double quotes in my batch file's parameters with escaped double quotes? This is my current batch file, which expands all of its command line parameters inside the string: @echo off call bash --verbose -c…
eplawless
  • 4,225
  • 7
  • 34
  • 35