escaping

How to escape underscore character in PATINDEX pattern argument?

坚强是说给别人听的谎言 提交于 2019-11-29 22:37:34
I've found a solution for finding the position of an underscore with PATINDEX : DECLARE @a VARCHAR(10) SET @a = '37_21' PRINT PATINDEX('%_%', @a) -- return 1 (false) PRINT PATINDEX('%!%', REPLACE(@a, '_', '!')) -- return 3 (correct) Have you other ideas? Like a way to escape the underscore character? Curt Hagenlocher I've always done it with brackets: '%[_]%' To match two underscores, each must be bracketed '%[__]%' -- matches single _ with anything after '%[_][_]%' -- matches two consecutive _ Charlie You can escape using the [ and ] characters like so: PRINT PATINDEX('%[_]%', '37_21') 来源:

Escaping the '\' character in the replacement string in a sed expression

爷,独闯天下 提交于 2019-11-29 20:35:33
问题 I am trying to take a line of text like 13) Check for orphaned Path entries and change it to (I want the bash color codes to colorize the output, not display on the screen) \033[32m*\033[0m Check for orphaned Path entries with bash color codes to colorize the asterisk to make it stand out more. I have a sed command that does most of that, except it doesn't handle the color codes correctly since it sees them as references to replacement text. What I have so far: sed "s/ *13) \(.*\)/ \033[32m*

How do I escape double quotes in attributes in an XML String in T-SQL?

我是研究僧i 提交于 2019-11-29 20:31:46
Pretty simple question - I have an attribute that I would like to have double quotes in. How do I escape them? I've tried \" "" \\" And I've made the @xml variable both xml type and varchar(max) for all of them. declare @xml xml --(or varchar(max) tried both) set @xml = '<transaction><item value="hi "mom" lol" ItemId="106" ItemType="2" instanceId="215923801" dataSetId="1" /></transaction>' declare @xh int exec sp_xml_preparedocument @xh OUTPUT, @xml insert into @commits --I declare the table, just removed it for brevity select x.* from openxml(@xh,'/transaction/item') WITH ( dataItemId int,

Spaces in java execute path for OS X

扶醉桌前 提交于 2019-11-29 18:31:12
问题 On OS X, I am trying to .exec something, but when a path contains a space, it doesn't work. I've tried surrounding the path with quotes, escaping the space, and even using \u0020. For example, this works: Runtime.getRuntime().exec("open /foldername/toast.sh"); But if there's a space, none of these work: Runtime.getRuntime().exec("open /folder name/toast.sh"); Runtime.getRuntime().exec("open \"/folder name/toast.sh\""); Runtime.getRuntime().exec("open /folder\\ name/toast.sh"); Runtime

JSON String inside a JSON

我怕爱的太早我们不能终老 提交于 2019-11-29 18:28:36
问题 I want to create a JSON string inside a JSON request. Here is my code, Fiddle JS var x = { a: 1, b: 'a sample text', }; var request = { t: JSON.stringify(x), c: 2, r: 'some text' }; console.log(request); Can someone help me how to escape the double quotes? Console Object { t: "{"a":1,"b":"a sample text"}", //This creates a problem, double quotes inside double quotes. c: 2, r: "some text" } Thanks in advance. 回答1: That's just the way the browser console shows you the value of a string, by

Adding text to database

你。 提交于 2019-11-29 18:15:47
I tried adding this text to the MySQL database with PHP and the $_POST method: HTML: <form name="addBook" action="?action=save" method="post" enctype="multipart/form-data"> <table> <tr> <td>Boek naam</td> <td><input type='text' name='book_name' required></td> </tr> <tr> <td>Genre</td> <td><input type='text' name='book_genre' required></td> </tr> <tr> <td>Cover</td> <td><input type='file' name='cover' id='cover'></td> </tr> <tr> <td>Text</td> <td><textarea cols='50' rows='20' name='book_text'>Schrijf hier</textarea></td> </tr> <tr> <td colspan="2"><input type="reset" name="reset" value="Remove

Default escaping in Freemarker

三世轮回 提交于 2019-11-29 18:12:01
问题 In Freemarker templates we can use the escape directive to automatically apply an escaping to all interpolations inside the included block: <#escape x as x?html> <#-- name is escaped as html --> Hallo, ${name} </#escape> Is there a way to programmatically achieve a similar effect, defining a default escape applied to all interpolations in the template, including those outside escape directives? Thanks. 回答1: To elaborate on Attila's answer: you can use a class like this one and then wrap your

How to escape URL-encoded data in POST with HttpWebRequest

…衆ロ難τιáo~ 提交于 2019-11-29 17:59:36
问题 I am trying to send an URL-encoded post to a REST API implemented in PHP. The POST data contains two user-provided strings: WebRequest request = HttpWebRequest.Create(new Uri(serverUri, "rest")); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.Headers.Add("Content-Transfer-Encoding", "binary"); // Form the url-encoded credentials we'll use to log in StringBuilder builder = new StringBuilder(); builder.Append("user="); builder.Append

htaccess rewrite rule with escaped ampersand in $_GET fails

时间秒杀一切 提交于 2019-11-29 17:31:11
问题 I am encountering a problem with a get parameter in conjunction with a htaccess rewrite rule. Below is the urlencode()'ed link; the rewrite rule I use to redirect to index.php, and lastly, a print_r($_GET) on the index.php. As you can see, the urlescaped ampersand is not part of the value for variable static, but instead and contrary to my expectation gets interpreted as a variable seperator. Why? Initial link: <a href="static/Game-Tech-%26-Arts-Lab">link</a> .htaccess: RewriteRule ^static/(.

SQL escape with sqlite in C#

强颜欢笑 提交于 2019-11-29 17:25:22
问题 I have a text field and its breaking my sql statement. How do i escape all the chars in that field? I am using sqlite with http://sqlite.phxsoftware.com/ in C# 回答1: You should be using a parameter as in: SQLiteCommand cmd = _connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT * FROM MyTable WHERE MyColumn = @parameter"; cmd.Parameters.Add( new SQLiteParameter( "@parameter", textfield ) ); SQLiteDataReader reader = cmd.ExecuteReader(); Using a parametrised