escaping

Why use \\x3C instead of < when generating HTML from JavaScript?

萝らか妹 提交于 2019-11-28 17:02:59
I see the following HTML code used a lot to load jQuery from a content delivery network, but fall back to a local copy if the CDN is unavailable (e.g. in the Modernizr docs ): <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script> <script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.1.min.js">\x3C/script>')</script> My question is, why is the last < character in the document.write() statement replaced with the escape sequence \x3C ? < is a safe character in JavaScript and is even used earlier in the same string, so why escape it there? Is it just to

Python “string_escape” vs “unicode_escape”

妖精的绣舞 提交于 2019-11-28 16:53:04
According to the docs , the builtin string encoding string_escape : Produce[s] a string that is suitable as string literal in Python source code ...while the unicode_escape : Produce[s] a string that is suitable as Unicode literal in Python source code So, they should have roughly the same behaviour. BUT, they appear to treat single quotes differently: >>> print """before '" \0 after""".encode('string-escape') before \'" \x00 after >>> print """before '" \0 after""".encode('unicode-escape') before '" \x00 after The string_escape escapes the single quote while the Unicode one does not. Is it

Elastic Search Hyphen issue with term filter

折月煮酒 提交于 2019-11-28 16:49:13
I have the following Elastic Search query with only a term filter. My query is much more complex but I am just trying to show the issue here. { "filter": { "term": { "field": "update-time" } } } When I pass in a hyphenated value to the filter, I get zero results back. But if I try without an unhyphenated value I get results back. I am not sure if the hyphen is an issue here but my scenario makes me believe so. Is there a way to escape the hyphen so the filter would return results? I have tried escaping the hyphen with a back slash which I read from the Lucene forums but that didn't help. Also,

Swift @escaping and Completion Handler

亡梦爱人 提交于 2019-11-28 15:17:26
I am trying to understand 'Closure' of Swift more precisely. But @escaping and Completion Handler are too difficult to understand I searched many Swift postings and official documents, but I felt it was still not enough. This is the code example of official documents var completionHandlers: [()->Void] = [] func someFunctionWithEscapingClosure(completionHandler: @escaping ()->Void){ completionHandlers.append(completionHandler) } func someFunctionWithNoneescapingClosure(closure: ()->Void){ closure() } class SomeClass{ var x:Int = 10 func doSomething(){ someFunctionWithEscapingClosure { self.x =

python IDLE shell appears not to handle some escapes correctly

╄→гoц情女王★ 提交于 2019-11-28 14:38:23
For example \b backspace prints as quad (shown as [] in example below). But \n newline is Ok. >>> print 'abc\bd' abc[]d >>> print 'abc\nd' abc d Im running under Vista (pro), python 2.7 Ive tried googling this issue generally and in SO and cant find anything relevant, which seems odd and makes me wonder if theres some setting or other may be wrong in my setup. Not sure what to look for. What am I doing wrong or what should I be looking for? Is it reasonable to expect backspace, specifically, to work? No, IDLE does not support backspace, nor carriage-return, nor formfeed, nor ANSI escape

Javascript: Replace backslashes with double backslashes

本秂侑毒 提交于 2019-11-28 14:27:37
I'm currently having the problem mentioned in the title and I'm somehow not finding a way to properly replace backsashes with double backslashes, so that I can properly give the string to a webservice as parameters. Let me show you what I tried. Some of these do actually work for some other people, but not for me... I'm currently testing this with FF18.0.1 WSParameters.replace(/\\/g, "\\\\\\\\"); WSParameters.replace("\\", "\\\\\\\\"); WSParameters.replace(/\\/g, "\\\\"); WSParameters.replace(/\\/g, "\\"); WSParameters.replace(/\\/g, "\"); WSParameters.replace("\\", "\\\\"); Thanks a lot in

Generating html with batch .. escape quotes

时光总嘲笑我的痴心妄想 提交于 2019-11-28 14:16:39
This is supposed to generate the hierarchy to a web document with the different files, it's because I'm lazy I made this. @echo off echo. echo This program will generate the base folder for a new website .. . pause md folders echo > folders/default.html "<html> /* More content */ </html>" echo > folders/style.css " /* All the standards i always use */ " echo > folders/javascript.js " /* All the standards i always use */ " echo. exit It also work but the problem is, I cannot remove/escape the quotes and that give hysterical moments though. I tried many different things. Changing echo with type,

Escaping double quotes with tcsh alias

落爺英雄遲暮 提交于 2019-11-28 13:51:30
I'm trying to run the following commands: replace -x "must " A2input.txt replace -x " a" -f -s ## A2input.txt replace -x to -s ## -a A2input.txt replace -x faith -f "unequivocal" A2input.txt And it'd be nice if I could just alias it to something short and simple like "a", "b", "c", "d", etc... However, some of those arguments have a quote, which is messing up the alias. Does anyone know how to actually escape the double quotes? I've tried things like '\"' and \" but nothing seems to work. I'm using tcsh as my shell. I got it to work by storing the string with the double quote in a variable

How to use '\\Q' and '\\E' regex symbols in python?

有些话、适合烂在心里 提交于 2019-11-28 13:45:15
I thought this should work, but it doesn't: import re if re.match("\Qbla\E", "bla"): print "works!" Why it doesn't work? Can I use the '\Q' and '\E' symbols in python? How? Python's regex engine doesn't support those; see §7.2.1 "Regular Expression Syntax" in the Python documentation for a list of what it does support. However, you can get the same effect by writing re.match(re.escape("bla"), "bla") ; re.escape is a function that inserts backslashes before all special characters. By the way, you should generally use "raw" strings, r"..." instead of just "..." , since otherwise backslashes will

How escape a “{” and a “}” in Inno Setup

╄→гoц情女王★ 提交于 2019-11-28 13:44:00
How can I escape the characters { and } in Inno Setup, the characters are used in the [Registry] section? { , "{" do not compile. %7d , "%7d" , {%7d} all compile, but do not work, they result in the wrong values in the registry. Best regards. You can escape the { by doubling it. There is no need to escape the } as it is only used if inside a constant. From the help file : A "{" character is treated as the start of the constant. If you want to use that actual character in a place where constants are supported, you must use two consecutive "{" characters. (You do not need to double "}"