escaping

How to remove escape sequences from stream

时光总嘲笑我的痴心妄想 提交于 2019-12-01 09:06:29
is there an quick way to find(and remove) all escape sequences from a Stream/String?? shamim Hope bellow syntax will be help full for you string inputString = @"hello world]\ "; StringBuilder sb = new StringBuilder(); string[] parts = inputString.Split(new char[] { ' ', '\n', '\t', '\r', '\f', '\v','\\' }, StringSplitOptions.RemoveEmptyEntries); int size = parts.Length; for (int i = 0; i < size; i++) sb.AppendFormat("{0} ", parts[i]); The escape sequences that you are referring to are simply text based represntations of characters that are normally either unprintable (such as new lines or tabs

Printing string in Perl

﹥>﹥吖頭↗ 提交于 2019-12-01 09:01:48
问题 Is there an easy way, using a subroutine maybe, to print a string in Perl without escaping every special character? This is what I want to do: print DELIMITER <I don't care what is here> DELIMITER So obviously it will great if I can put a string as a delimiter instead of special characters. 回答1: perldoc perlop, under "Quote and Quote-like Operators", contains everything you need. While we usually think of quotes as literal values, in Perl they function as operators, providing various kinds of

How to escape a NULL byte as an argument to a shell command inside a Makefile

不羁的心 提交于 2019-12-01 08:57:22
问题 Inside a Makefile I run a shell command which I want to pass a NULL byte as argument. The following attempt fails: echo $(shell /bin/echo -n $$'\x00' | ruby -e "puts STDIN.read.inspect") It generates: echo "$\\x00" Instead I expected: echo "\u0000" How do I properly escape such a NULL byte? 回答1: echo disables interpretation of backslash escapes by default. You need to supply the -e option to enable it. $ echo -ne "\x00" | ruby -e "puts STDIN.read.inspect" "\u0000" 回答2: Due to the execve(2)

How to escape certain characters in java

∥☆過路亽.° 提交于 2019-12-01 08:49:54
I need to escape characters like ^ , . , [ , ] , + and \ (tabs and newlines won't be an issue), while leaving others like * and ? . EDIT = More specifically, I have a string with these characters, and I need to escape them so that they are not matched by regular expressions. I need to prepend \ to each of these characters, but doing so individually would take 7 or 8 scans and I'd like to do it within just one pass (IE: anything that matches is prepended with \ ) How do I do this? Thanks. Would this work? StringBuilder sb = new StringBuilder(); for (char c : myString.toCharArray()) { switch(c)

What is the proper time to use real_escape_string? When data arrives in POST, or just before composing the query?

南笙酒味 提交于 2019-12-01 08:21:50
We know that to prevent SQL injection problems string values must be escaped before the SQL query is composed -- particularly those from users or other external sources. When should this escaping be done? Should it be done as the value enters the program, storing the escaped value for later use? Or should store the unescaped value, and escape it just as the query is being composed? Which approach is safer? What is the tradeoff? 1) example of escaping as the value is received: $test = $mysqli->real_escape_string($_POST['test']); . . . $query=" UPDATE * from test_panel where test='" . $test . "'

keep textarea input format after using mysql_real_escape_string to store

左心房为你撑大大i 提交于 2019-12-01 08:01:22
I am using php5.3.6 and mysql 5.1.56 and CodeIgniter. Here is what I did. Input some text in textarea, something like this: what's this? I'm bob. $string = $_POST['name']; $insertdata = mysql_real_escape_string($string); Insert $insertdata into database. It shows "what\'s this?\n\n\nI\'m bob."(without double quotes) in the table. Query the data stored in database, use stripslashes on it and then put it back to the textarea. It shows "what's this?nnnI'm bob."(without double quotes) in the textarea. My questions are: In step 4, shouldn't it be "what\'s this?\n\n\n I\'m bob." stored in the table?

Bash echo command not making use of escaped character

我是研究僧i 提交于 2019-12-01 07:54:54
The bash echo command isn't using the escaped characters like "\n" and "\t" echo "This is test string\nAnd this is next line" For the above input it displays This is test string\nAnd this is next line So how do I print on the next line? You need echo -e if you want escaped characters to be expanded: $ echo -e "This is test string\nAnd this is next line" This is test string And this is next line $ echo $'This is test string\nAnd this is next line' This is test string And this is next line ANSI-C Quoting Words of the form $'string' are treated specially. The word expands to string, with

Triple single quote vs triple double quote in Ruby

烂漫一生 提交于 2019-12-01 07:33:55
Why might you use ''' instead of """ , as in Learn Ruby the Hard Way, Chapter 10 Study Drills ? There are no triple quotes in Ruby. Two String literals which are juxtaposed are parsed as a single String literal. So, 'Hello' 'World' is the same as 'HelloWorld' And '' 'Hello' '' is the same as '''Hello''' is the same as 'Hello' There are no special rules for triple single quotes vs. triple double quotes, because there are no triple quotes. The rules are simply the same as for quotes. mmln I assume the author confused Ruby and Python, because a triple-quote will not work in Ruby the way author

What is the proper time to use real_escape_string? When data arrives in POST, or just before composing the query?

微笑、不失礼 提交于 2019-12-01 07:12:30
问题 We know that to prevent SQL injection problems string values must be escaped before the SQL query is composed -- particularly those from users or other external sources. When should this escaping be done? Should it be done as the value enters the program, storing the escaped value for later use? Or should store the unescaped value, and escape it just as the query is being composed? Which approach is safer? What is the tradeoff? 1) example of escaping as the value is received: $test = $mysqli-

escape less / greater than javascript

给你一囗甜甜゛ 提交于 2019-12-01 07:08:07
I'm having a problem trying to escape some code... Basically, I want to escape "<" and ">" but I want them to APPEAR in my #output div as "<" and ">". Currently, they appear as as "<" and ">" on the page. This is obviously to prevent anyone exploiting / injecting scripts on the page. This is my code: var textval = $("#textarea").val(); //textarea filtered = textval.replace(/</gi,"<"); //replace "<" $("#output").html(filtered); //insert textarea data into div Can anybody spot what I am doing wrong, or are there any better ways of doing this? Many thanks EDIT: I do want SOME html tags (like <b>