escaping

JavaScript: Escaping double quotes in HTML

别来无恙 提交于 2019-12-10 13:06:15
问题 How can I prevent the images[i].title below from breaking the HTML if it contains double quotes? for (i=0; i<=images.length-1; i++) { gallery += '<img width="250" height="250" src="' + images[i].src + '" title="' + images[i].title + '" />'; } 回答1: You can use the replace() method to escape the double quotes: for (var i = 0; i < images.length; ++i) { gallery += '<img width="250" height="250" src="' + images[i].src + '" title="' + images[i].title.replace(/\"/g, '\\"') + '" />'; } The result

How to insert a line break in a StringVar in Crystal Reports

强颜欢笑 提交于 2019-12-10 13:05:38
问题 How do I enter a line break (or other non-text characters usually solved with escape characters) in a StringVar in Crystal Reports? Wanted output: line 1 line 2 I've tried StringVar s := "line 1 \n line 2"; , but that does not work. 回答1: It may not be much of an improvement, but you could build a string-formatting, custom function: // sf() Function (Stringvar text) Stringvar Array keys := ["\n"]; Stringvar Array values := [Chr(10)+Chr(13)]; Numbervar i; For i := 1 to Ubound(keys) do ( text :=

perl string escape [closed]

╄→гoц情女王★ 提交于 2019-12-10 12:25:51
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I wish to escape special characters susch as quotes and spaces in a Perl string. I'd like to avoid using regex and installing extra modules. 回答1: Using quotemeta may help you. my $escaped = quotemeta $string_with

extracting key value pairs from a string containing escaped characters

淺唱寂寞╮ 提交于 2019-12-10 12:18:36
问题 this question builds on: get python dictionary from string containing key value pairs I'd like to get key, value pairs with values that contain equals signs that are escaped out. r = "key1=value1 key2=value2 request=http://www.pandora.com/json/music/artist/justin-moore?explicit\\=false uri=3DLoiRDsBABCAA9FvE1htRg\\=\\=" regex = re.compile(r"\b(\w+)=([^=]*)(?=\s\w+=\s*|$)") d = dict(regex.findall(r)) print(d) {'key2': 'value2', 'key1': 'value1'} I cannot seem to get the values with escaped

How to automatically escape strings in a PHP SQL query?

こ雲淡風輕ζ 提交于 2019-12-10 12:07:52
问题 Here's how I currently do it: $db->query(sprintf('INSERT INTO pages (title, content) VALUES ("%s", "%s")', $db->esc($title), $db->esc($content))); As you can see I'm manually escaping each string in the above query by passing each string to my $db->esc() method. First let me indicate that I don't want to use prepared statements. The best idea I can come up with is to have my $db->query() method wrap sprintf() and automatically call $db->esc() on each string conversion specification - like

Restarting process on -XX:OnOutOfMemoryError using shell script gives: Unrecognized option: -9

泄露秘密 提交于 2019-12-10 12:05:47
问题 I'm trying to restart process when OOME happens. Java binary is launched using two shell scripts, one of them imports other. I don't have any control of the first one but can modify the second one as I want. This is a prototype what I'm trying to do: First shell script test.sh: #!/bin/sh JAVA_OPTS="$JAVA_OPTS -Xmx10m" . test1.sh echo $JAVA_OPTS java $JAVA_OPTS $es_params TestMemory Second shell script test1.sh: #!/bin/sh pidfile="test.pid" touch $pidfile params="$parms -Dpidfile=$pidfile"

Escape Html in erlang

江枫思渺然 提交于 2019-12-10 11:39:04
问题 Does anyone have a good way to escape html tags in erlang (as for CGI.escapeHtml in Ruby)? Thanks 回答1: Well, i would tell you to roll your own method using string and list processing But, i would also say that if you have yaws web server source, there is a method i have used and copied into my own libraries. yaws_api:url_encode(HtmlString) . See it here in action. 1> Html = "5 > 4 = true". "5 > 4 = true" 2> yaws_api:url_encode(Html). "5%20%3E%204%20%3D%20true" 3> I hope this is some how what

A string replace function with support of custom wildcards and escaping these wildcards in C#

旧街凉风 提交于 2019-12-10 11:36:26
问题 I need to write a string replace function with custom wildcards support. I also should be able to escape these wildcards. I currently have a wildcard class with Usage, Value and Escape properties. So let's say I have a global list called Wildcards . Wildcards has only one member added here: Wildcards.Add(new Wildcard { Usage = @"\Break", Value = Enviorement.NewLine, Escape = @"\\Break" }); So I need a CustomReplace method to do the trick. I should replace the specified parameter in a given

Why does this triple quoting solution fix path error?

左心房为你撑大大i 提交于 2019-12-10 11:33:41
问题 So I was running into a bit of a problem today with this bit of code: os.system("C:\Program Files (x86)\DOSBox-0.72\dosbox.exe") Upon execution I'd get this error message: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. I assumed it was something to do with either the white space or the brackets, so I did a bit of digging online and after countless of ineffective "solutions" involving escape characters, I ended up finding a rather strange

Populate an input field with a string that contains a double quote

荒凉一梦 提交于 2019-12-10 11:19:59
问题 I'm getting a value back from the server that contains a double quote in it. I need to populate an input tag with the value. I've tried using escape(myVariable), but that converts the spaces to %20, etc. I suppose I could write an if/then that says if there's a double quote in the field, then use value='', but then what do I do if they have both double and single quotes in the field? 回答1: input.value = val.replace(/"/g, '"'); 回答2: Replace double quotes with " . 回答3: I'm getting a value back