escaping

Is there a method in shell to ignore escape characters?

ε祈祈猫儿з 提交于 2019-12-06 16:27:41
In C#, there is a verbatim string so that, string c = "hello \t world"; // hello world string d = @"hello \t world"; // hello \t world I am new to shell script, is there a similar method in shell? Because I have many folders with the name like "Apparel & Accessories > Clothing > Activewear", I want to know if there is a easy way to process the escape characters without write so many . test.sh director="Apparel & Accessories > Clothing > Activewear" # any action to escape spaces, &, > ??? hadoop fs -ls $director For definining the specific string in your example, Apparel & Accessories >

Escaping of JSON control characters within string

房东的猫 提交于 2019-12-06 15:57:37
问题 While writing a JSON parser in Java I ran into a "cosmetic" problem: In the JSON specification it's clearly said that Javascript control characters are the same as e.g. in C and Java, like \n or \t. The problem I was running into, is that when there are control codes within a JSON string (so within the quotes: "property":"value"), then the displayed JSON code is messed up because the control characters are changing the print, e.g. \n creates a new line or \t creates a tab. An example: String

Allow user to enter escape characters in a TextBox

陌路散爱 提交于 2019-12-06 15:56:44
I have a Windows.Forms.TextBox that I'd like to allow the user to enter escape sequences that are then interpreted as the character they represent. For example, if the following is entered: Hello\r\nWorld I'd like it to be stored as the character array: H e l l o \r \n W o r l d 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0D, 0x0A, 0x57, 0x6F, 0x72, 0x6C, 0x64 Thus far, I'm using the following to handle '\r' and '\n', but I'd also like to be able to handle any other escape sequence, like \u001A (ctrl+z), or \u001B (esc) string str = txtBox.Text.Replace("\\r","\r").Replace("\\n","\n"); ...There has to be a

What is the difference between a single and double escape (backslash) in Javascript string?

孤人 提交于 2019-12-06 14:33:46
问题 After attempting to answer the question to this post Another SO post I noted that this Function('return "\\101\\40\\171\\145\\154\\154\\157\\167\\40\\142\\165\\164\\164\\157\\156\\56"')() or Function('return "\101\40\171\145\154\154\157\167\40\142\165\164\164\157\156\56"')() both return the same string - "A yellow button." In regards to the question I linked to above, the JS code snippet is run in a tag. I have also noted in the past that when working on some JSON strings, that the '\' was

Can't pass a script block as a parameter to powershell.exe via -Command

送分小仙女□ 提交于 2019-12-06 14:00:46
问题 I'm trying this $Global:commandBlock={ Start-Transcript -path $projectFolder\gruntLog.txt; grunt $argList; Stop-Transcript } $cmdProc=start-process powershell -ArgumentList ('-command `$Global:commandBlock') -WorkingDirectory $fwd -PassThru -NoNewWindow:$NoNewWindow And keep getting $commandBlock : The term '$Global:commandBlock' is not recognized as the name of a cmdlet, function, script file, or operable program. My guess was it has to do with scope. But making variable global didn't help.

NSString strip regular \\ escape characters how?

人盡茶涼 提交于 2019-12-06 13:14:48
I need an efficient piece of code that strips escape characters. This is regular escapes not HTML escape characters. Example: "\"", "\\\\", "\", "\\" I want a general algorithm to strip any kind of escape sequences. Could use any utility like regular expression. (NSString*) unescape:(NSString*) string { .... } This is the answer I wrote: -(NSString*) unescape:(NSString*) string { for(int i = 0; i < string.length; i++) { char a = [string characterAtIndex:i]; if([string characterAtIndex:i] == '\\' ) { string = [string stringByReplacingCharactersInRange:NSMakeRange(i,1) withString:@""]; } }

VTD-XML seems to be spoiling escaped string in XML document

∥☆過路亽.° 提交于 2019-12-06 12:35:39
I am working on an XML data set (the DrugBank database available here ) where some fields contain escaped XML characters like "&", etc. To make the problem more concrete, here is an example scenario: <drugs> <drug> <drugbank-id>DB00001</drugbank-id> <general-references> # Askari AT, Lincoff AM: Antithrombotic Drug Therapy in Cardiovascular Disease. 2009 Oct; pp. 440–. ISBN 9781603272346. "Google books":http://books.google.com/books?id=iadLoXoQkWEC&pg=PA440. </general-references> . </drug> <drug> ... </drug> ... </drugs> Since the entire document is huge, I am parsing it as follows: VTDGen gen

Is there a pattern for creating escape characters in string?

帅比萌擦擦* 提交于 2019-12-06 12:11:32
问题 I am creating a string formatter in javascript that uses backslashes for escapes. Creating the formatter itself has been pretty easy. My issue is finding the escape characters, and doing the escapes in the formatter. This formatter copies the .Net formatting implementation into Javascript. Based off these notes: http://msdn.microsoft.com/en-us/library/26etazsy For example: "####\\###".format(123456) == "123#456"; Regex has been problematic because regex negation is not supported in JS. What I

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

我怕爱的太早我们不能终老 提交于 2019-12-06 11:22:49
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? input.value = val.replace(/"/g, '"'); Replace double quotes with " . I'm getting a value back from the server that contains a double quote in it. You flagged your question as "javascript" so I assume you are

Escaping inline code block in Asp.Net template

时光怂恿深爱的人放手 提交于 2019-12-06 11:16:50
I have a page where I wish to render the following html (a small JS template)- <script type="text/html" id="lightbox-template"> <div id="lightbox-background"></div> <div id="lightbox"><%= content %><div class="bottom"></div></div> </script> However, the Asp.NET preprocessor is picking up on the "<%=" tag and trying to interpret it. I wish to escape this tag to allow it to be rendered, preferably from the template rather than the code behind. Is this possible? I have managed to do this via a Literal control and setting it's text in the code behind. I ideally wanted to keep it within the aspx