escaping

Escape String - Output rails string in Javascript [duplicate]

假装没事ソ 提交于 2019-12-20 11:30:35
问题 This question already has answers here : How to pass Ruby variables to a JavaScript function in a Rails view? (6 answers) Closed 5 years ago . I'm trying to assign a string value to a javascript object in my .erb file like so: var data = { 'name': '<%= @product.name %>', ... }; The problem is, if the value of name is Tom's small ears , the output of data.name would be Tom's small ears . Is there a way to escape special characters? I tried doing 'name': '<%= raw @product.name %>' but Uncaught

Replace Double Quotes Within Attributes only in XML : C#

守給你的承諾、 提交于 2019-12-20 07:47:43
问题 I've this string which will be part of an XML/XML Node: string a = "<Node a=\"a\"[\"\"/>"; I need only the attribute quotes to be escaped so that it becomes a= "Node a=\"a&qout;[&qout;\"/>"; I'm using C#, .NET 2.0. 回答1: The link you found was correct, it just had to be adapted to C#. Here is the conversion : using System; using System.Collections.Generic; using System.Text; namespace RegEx { class Program { static void Main(string[] args) { string text = "<Node a=\"a\"[\"\" b=\"b\"[\"\"/>

What is the most aesthetic way to to escape a single quote within a single-quoted string in (ba)sh?

谁说我不能喝 提交于 2019-12-20 07:37:45
问题 In a (ba)sh script of mine, I have, for example: MYVAR='Alice says: "Hello, Bob." But Bob isn't listening.' This is a syntax error, since the ' in isn't ends the single-quoted string. I know I can fix this using MYVAR='Alice says: "Hello, Bob." But Bob isn'"'"'t listening.' But that is sooo ugly... what can I do instead? sh doesn't support MYVAR='Alice says: "Hello, Bob." But Bob isn\'t listening.' Which would have been tolerable, and switching to a double-quotes string is not an option for

Escaping dynamic sqlite query?

被刻印的时光 ゝ 提交于 2019-12-20 06:45:06
问题 I'm currently building SQL queries depending on input from the user. An example how this is done can be seen here: def generate_conditions(table_name,nameValues): sql = u"" for field in nameValues: sql += u" AND {0}.{1}='{2}'".format(table_name,field,nameValues[field]) return sql search_query = u"SELECT * FROM Enheter e LEFT OUTER JOIN Handelser h ON e.Id == h.Enhet WHERE 1=1" if "Enhet" in args: search_query += generate_conditions("e",args["Enhet"]) c.execute(search_query) Since the SQL

Label property to accept escape sequences in C# [duplicate]

末鹿安然 提交于 2019-12-20 06:36:52
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Enter “&” symbol into a text Label in Windows Forms? Is there any property for a label to display '&' in C#? I'm trying to display customer names in a label. When there is any '&' symbol in the name, it's getting displayed as '_'. For example, A&B XXX is getting displayed as AB with B underlined. Instead of hardcoding, is there any way to display & symbols as received by means of setting any property? 回答1: The

How to add apostrophe (") to string?

放肆的年华 提交于 2019-12-20 05:26:08
问题 I have this AutoIt script: ControlFocus("Open", "", "Edit1") Sleep(500) ControlSetText("Open", "", "Edit1", $CmdLine[1]) Sleep(500) ControlClick("Open", "", "Button1") It types a file name inside a file selection window. I want to add " before and after my string (the string I send as command line argument to my script). I tried ControlSetText("Open", "", "Edit1", $CmdLine[1] & """) but this results into error: Unterminated string. . 回答1: Autoit uses pairs quotes to indicate a single instance

Passing arguments form java program to bash script that call another java programa with the arguments

℡╲_俬逩灬. 提交于 2019-12-20 04:53:32
问题 I want to executing a shell scripting in my java program passing a argument showed bellow: Runtime.getRuntime().exec("./test.sh " + "\\\"param1\\\"\\\"param2\\\"\\\"param3\\\""); And the test.sh will call another java program passing the string argument like this: another.jar \"param1\"\"param2\"\"param3\" and finally the program anther.jar will interpret the argument in this format another.jar "param1""param2""param3" I'm a bit confuse with this bacause I can't deal correctly with escapes

Passing arguments form java program to bash script that call another java programa with the arguments

北城余情 提交于 2019-12-20 04:53:12
问题 I want to executing a shell scripting in my java program passing a argument showed bellow: Runtime.getRuntime().exec("./test.sh " + "\\\"param1\\\"\\\"param2\\\"\\\"param3\\\""); And the test.sh will call another java program passing the string argument like this: another.jar \"param1\"\"param2\"\"param3\" and finally the program anther.jar will interpret the argument in this format another.jar "param1""param2""param3" I'm a bit confuse with this bacause I can't deal correctly with escapes

Escaping quotes in a javascript string

无人久伴 提交于 2019-12-20 04:53:08
问题 I'm trying to escape the quotes (and apostrofes and escape char) in a text string in javascript: var text = 'Escape " and \' and /.'; var rx = new RegExp('/([\'"])/g'); console.log(text, ' ==> ', text.replace(rx,'//\1'));​​​​​ What I expect to be output is Escape /" and /' and //. , but instead I get Escape " and ' and /. . I just can't seem to get this working and don't know what's wrong. Here's a JSFiddle: http://jsfiddle.net/hvtgf/ 回答1: Escaping means using backslash \ but not slash / .

How to pass quoted parameters to another program

依然范特西╮ 提交于 2019-12-20 04:19:52
问题 In a bash script, I need to pass a parameter to another program. The parameter has spaces in so must be quoted. Everything works fine in this simple case 1: /bin/echo /some/command --param="abc def ghi" Output: /some/command --param=abc def ghi The problem begins if I want to make the bash script more sophisticated, somehow the parameter value has changed in case 2 and 3: FOO="ghi" DEFAULTS="--param=\"abc def $FOO\"" /bin/echo /some/command $DEFAULTS DEFAULTS='--param="abc def '$FOO'"' /bin