Questions tagged [escaping]

Escaping is the process of applying an alternate meaning to a character or set of characters.

Escaping is used for many purposes, such as providing representations of unprintable characters, changing font colors in terminals, or allowing the inclusion in a string of a character normally used to terminate the string, as well as allowing to output a character to user when that character can be used as a control or markup character.

Some of the more common uses of escaping

  • URL encoding to allow including characters such as / or ?, and others, in URL queries;
  • XML and HTML entities that can be used to encode special characters that, for example, would normally be used for markup purposes.
8924 questions
8 answers

How to escape indicator characters (colon and hyphen) in YAML

In a config file, I have a key to which I wish to assign a URL. The problem is that YAML interprets : and - characters as either creating mappings or lists, so it has a problem with the line url: http://www.some-site.example/ (both because of the…
  • 4,743
  • 3
  • 18
  • 20
11 answers

How to use a variable inside a regular expression

I'd like to use a variable inside a regex, how can I do this in Python? TEXTO = sys.argv[1] if"\b(?=\w)TEXTO\b(?!\w)", subject, re.IGNORECASE): # Successful match else: # Match attempt failed
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
8 answers

How to escape text for regular expression in Java?

Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input.
  • 31,662
  • 4
  • 34
  • 33
5 answers

How to execute a bash command stored as a string with quotes and asterisk

I try to execute the following command : mysql AMORE -u username -ppassword -h localhost -e "SELECT host FROM amoreconfig" I store it in a string : cmd="mysql AMORE -u username -ppassword -h localhost -e\"SELECT host FROM amoreconfig\"" Test…
  • 15,135
  • 20
  • 70
  • 105
6 answers

How do I properly escape quotes inside HTML attributes?

I have a drop down on a web page which is breaking when the value string contains a quote. The value is "asd, but in the DOM it always appears as an empty string. I have tried every way I know to escape the string properly, but to no avail.
  • 3,702
  • 3
  • 23
  • 15
12 answers

What is the recommended way to escape HTML symbols in plain Java?

Is there a recommended way to escape <, >, " and & characters when outputting HTML in plain Java code? (Other than manually doing the following, that is). String source = "The less than sign (<) and ampersand (&) must be escaped before using them…
Ben Lings
  • 28,823
  • 13
  • 72
  • 81
10 answers

How can I escape square brackets in a LIKE clause?

I am trying to filter items with a stored procedure using like. The column is a varchar(15). The items I am trying to filter have square brackets in the name. For example: WC[R]S123456. If I do a LIKE 'WC[R]S123456' it will not return anything. I…
  • 3,389
  • 2
  • 19
  • 11
6 answers

How to properly escape a double quote in CSV?

I have a line like this in my CSV: "Samsung U600 24"","10000003409","1","10000003427" Quote next to 24 is used to express inches, while the quote just next to that quote closes the field. I'm reading the line with fgetcsv but the parser makes a…
  • 4,783
  • 6
  • 29
  • 45
7 answers

Which characters need to be escaped when using Bash?

Is there any comprehensive list of characters that need to be escaped in Bash? Can it be checked just with sed? In particular, I was checking whether % needs to be escaped or not. I tried echo "h%h" | sed 's/%/i/g' and worked fine, without escaping…
  • 275,237
  • 103
  • 548
  • 598
34 answers

Unescape HTML entities in JavaScript?

I have some JavaScript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form: However, when I use the JavaScript to insert the strings into HTML, they render literally. I don't see an image,…
Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
11 answers

How do I use spaces in the Command Prompt?

How can I use spaces in the Windows Command Line? cmd /C C:\Program Files (x86)\WinRar\Rar.exe a D:\Hello 2\File.rar D:\Hello 2\*.*
  • 19,053
  • 44
  • 104
  • 146
6 answers

Convert XmlDocument to String

Here is how I'm currently converting XMLDocument to String StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); xmlDoc.WriteTo(xmlTextWriter); return stringWriter.ToString(); The problem…
  • 12,034
  • 24
  • 73
  • 85
13 answers

Escape quotes in JavaScript

I'm outputting values from a database (it isn't really open to public entry, but it is open to entry by a user at the company -- meaning, I'm not worried about XSS). I'm trying to output a tag like this:
Matt Dawdy
  • 19,247
  • 18
  • 66
  • 91
7 answers

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 ".help" for instructions sqlite> .read…
  • 16,622
  • 34
  • 63
  • 66
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
  • 5,986
  • 5
  • 35
  • 49