escaping

Escape characters when executing powershell command in batch script

≡放荡痞女 提交于 2020-01-02 07:13:16
问题 I want to execute powershell command and put it in batch variable The command: for /f "delims=" %%i in ('powershell ^(Get-ChildItem ""\dir\"" -Name | sort-object {\[regex\]::Replace^($_,^'\d+^',{$args\[0\].Value.PadLeft^(20^)}^)} | select -last 1^) ') do set output=%%i It can't be executed due special character. In addition, I can't pause the window so it closes before I can see what is the problem. I think the problem is with the pipe "|", because the following command does work(the part

WARNING: nonstandard use of escape in a string literal

拟墨画扇 提交于 2020-01-02 05:38:09
问题 I have query to remove double space and convert it to single space. UPDATE tablename SET name=trim(regexp_replace(name,'\s\s+',' ', 'g')); It gives error: WARNING: nonstandard use of escape in a string literal HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. 回答1: You are running an old version of Postgres with the setting escape_string_warning = on (default) and standard_conforming_strings = off ( outdated! , default is on since Postgres 9.1). The manual: escape_string_warning (

PHP and backslashes in strings

混江龙づ霸主 提交于 2020-01-02 04:51:11
问题 Can anyone tell me what is happening here? <?php // true var_dump('\\ ' === '\ '); // false var_dump('\\\\ ' === '\\ '); // true var_dump('\\\\ ' === '\\\ '); 回答1: \ inside a string literal introduces several types of escape sequences, \\ is the escape sequence for a literal "\". But, \ s that don't resolve to an escape sequence are also taken as literal "\". Therefor, '\\ ' stands for the string "\ ", '\\\\ ' stands for the string "\\ ", just as '\\\ ' . Try: echo '\\\\ '; -> \\ See http:/

PHP and backslashes in strings

那年仲夏 提交于 2020-01-02 04:51:09
问题 Can anyone tell me what is happening here? <?php // true var_dump('\\ ' === '\ '); // false var_dump('\\\\ ' === '\\ '); // true var_dump('\\\\ ' === '\\\ '); 回答1: \ inside a string literal introduces several types of escape sequences, \\ is the escape sequence for a literal "\". But, \ s that don't resolve to an escape sequence are also taken as literal "\". Therefor, '\\ ' stands for the string "\ ", '\\\\ ' stands for the string "\\ ", just as '\\\ ' . Try: echo '\\\\ '; -> \\ See http:/

Filesystem filename escape? C#

最后都变了- 提交于 2020-01-02 02:41:58
问题 I am allowing the user to choose any username he wants and it can be anything at all such as AC♀¿!$"Man'@ Now i need to create a directory for him. What function i use to escape the text so i dont a FS problem/exception? 回答1: Use Path.GetInvalidFileNameChars or Path.GetInvalidPathChars to check for characters to remove. http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx 回答2: Whether you replace invalid characters or remove them, there's always going to be the

bash tips needed for understanding how to escape characters in command-line

╄→尐↘猪︶ㄣ 提交于 2020-01-01 19:51:27
问题 My knowledge of commandline bash is missing on a particular area: I constantly forget how to properly escape characters. Today I wanted to echo this string into a file: #!/bin/env bash python -m SimpleHTTPServer However, this fails: echo "#!/bin/env bash\npython -m SimpleHTTPServer" > server.sh && chmod +x server.sh -bash: !/bin/env: event not found That's right: Remember to escape ! or bash will think it's a special bash event command. But I can't get the escaping right! \! yields \! in the

ASCII to HTML-Entities Escaping in Java

我是研究僧i 提交于 2020-01-01 15:10:35
问题 I found this website with escape codes and I'm just wondering if someone has done this already so I don't have to spend couple of hours building this logic: StringBuffer sb = new StringBuffer(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); switch (c) { case '\u25CF': sb.append("●"); break; case '\u25BA': sb.append("►"); break; /* ... the rest of the hex chars literals to HTML entities */ default: sb.append(c); break; } } 回答1: These "codes" is a mere decimal

ASCII to HTML-Entities Escaping in Java

允我心安 提交于 2020-01-01 15:10:05
问题 I found this website with escape codes and I'm just wondering if someone has done this already so I don't have to spend couple of hours building this logic: StringBuffer sb = new StringBuffer(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); switch (c) { case '\u25CF': sb.append("●"); break; case '\u25BA': sb.append("►"); break; /* ... the rest of the hex chars literals to HTML entities */ default: sb.append(c); break; } } 回答1: These "codes" is a mere decimal

Convert characters in a c string to their escape sequences

别来无恙 提交于 2020-01-01 11:46:29
问题 I need a function like string ToLiteral(string input) from this post. Such that char *literal = to_literal("asdf\r\n"); Would yield literal ==> "asdf\\r\\n" . I've googled around, but not been able to find anything (guess that I've must be using the wrong terms). However, I assume that a library with this functionality must be out there somewhere... Thank you for the interresting answers. Googling "c string escape function" by the way seems to be the key to obtaining even more examples and

Create a mapping for Vim's command-line that escapes the contents of a register before inserting it

眉间皱痕 提交于 2020-01-01 09:08:13
问题 Suppose that I have a document like this, and I want to search for all occurences of the URL: Vim resources: [http://example.com/search?q=vim][q] ... [q]: http://example.com/search?q=vim I don't want to type it out in full, so I'll place my cursor on the first URL, and run "uyi[ to yank it into the 'u' register. Now to search for it, I'd like to just paste the contents of that register into the search field by running: /\V<c-r>u<CR> This results in Vim searching for the string 'http:' -