escaping

how to escape slashes in perl text used in a regular expression?

end_date=$(date +"%m/%d/%Y") /usr/bin/perl -pi -e "s/_end_date_/${end_date}/g" filename I want to replace string '_end_date_' with current date. Since current date has slashes in it(yes I want the slashes), I need to escape them. How can I do this? I've tried several ways like replacing slashes with "\/" using sed and perl itself but ...

Backslashes in gsub (escaping and backreferencing)

Consider the following snippet: puts 'hello'.gsub(/.+/, '\0 \\0 \\\0 \\\\0') This prints (as seen on ideone.com): hello hello \0 \0 This was very surprising, because I'd expect to see something like this instead: hello \0 \hello \\0 My argument is that \ is an escape character, so you write \\ to get a literal backslash, thus \\...

In Java, is there a way to write a string literal without having to escape quotes?

Say you have a String literal with a lot of quotation marks inside it. You could escape them all, but it's a pain, and difficult to read. In some languages, you can just do this: foo = '"Hello, World"'; In Java, however, '' is used for chars, so you can't use it for Strings this way. Some languages have syntax to work around this. Fo...

Escaping slash in Postgresql

I'm trying to write an sql function in Postgresql that will parse a file path. I want to return just the file name. I cannot get past getting an accurate text string in the function. Here is the function: Function: job_page("inputText" text) DECLARE $5 text; BEGIN $5 = quote_literal("inputText"); return $5; END When I run this: sele...

MySQL equivalent of PQexecParams?

Does libmysqlclient have an equivalent to libpq's PQexecParams which allows you to send params separately from the query string, making SQL injection impossible and escaping special characters unnecessary? I couldn't find anything except the prepared statement API which seems to be rather complicated/overkill for such a simple thing. Ho...

PHP preg_match: escaping { and }

Hello. I am facing a little problem. My string is From {start} to {end} and I want to validate it using preg_match() to avoid illegal chars. preg_match("/^[a-zA-Z\{\} ]{1,}$/",$var) The point is the escape for { and }. thanks :) ...

Replace all &#60; with < with perl on cygwin

I have Cygwin installed, I want to execute something like this on the command prompt: perl -pne 's/&#60;/<' input > output But I'm running into two separate issues with the & and < each needing to be escaped. something like 's/&/&' is an error at the perl level "Substitution pattern not terminated at -e line 1" something like 's/...

escape & in url

Hi all How can I escape & (ampersand) in url with the correct replacement in the jQuery function. I have tried .replace("/&/g", "&amp;") .replace("/&/g", "%26") .replace("/&/g", "\&") But nothing is working. If anyone has idea please share with me. Thanks ...

How to escape URL-encoded data in POST with HttpWebRequest

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-Encod...

Escape html in python?

i have a <img src=__string__> but string might contain ", what should I do to escape it? Example: __string__ = test".jpg <img src="test".jpg"> doesn't work. ...

Oracle 8, SQL: RTRIM for string manipulation is not working as expected

Oracle 8 SQL: I do have data like "VTR 564-31 / V16 H12 W08 E19 L14" from which I want to trim the second part => "VTR 564-31" According to this website I can use the rtrim function rtrim('123000', '0'); would return '123' like this it works, but adapted to my use case, the following one does not trim at all? Do I have to escap...

How do I escape a field variable in an awk command in an alias?

Here are the contents of a file: one two three four five six And here is my alias alias testawk "awk '{print $2}' file" This is what I get: > testawk one two three four five six But when I give this command, then I get what I want: > awk '{print $2}' file two five How do I escape the field specifier in the alias? NOTE: I'm us...

String.Format escaping VB vs C#

While searching on how to escape a single quote in String.Format, I found the answer at SO: Escaping single quote in String.Format() It seems to be different for VB though. I tested it, and indeed C# needs string s = DateTime.Now.ToString("MMM d \\'yy 'at' H:mmm"); while VB needs Dim s As String = Now.ToString("MMM d \'yy 'at' H:mmm...

Send Contents of a Div via jQuery

I'd really like to take all of the html in a div (contains many other divs, form elements, etc), urlencode it (maybe) and then do an ajax post to a server side handler so that I can save the exact state of what the user is seeing. I would then like to be able to take that string that I've saved in a database and send it back in response...

Colon in JSON string

Can I escape a colon : that is inside a JSON string? Currently this object/value set { pn: "MT46H128M16LFCK-5 IT:A", visible: false, url: "/$ws$/29/1/products/ProductDetails.html?product=products/dram/MT46H128M16LFCK-5 IT" } doesn't get read. I suspect it's due to the :A in the pn value. How do I escape it or otherwise grab it...

Qt - Esc should not close the dialog.

How to make Esc key to minimize a dialog? By default it closes. Should I process KeyEvent or there is a better way? ...

Escaping output safely for both html and input fields

In my web app, users can input text data. This data can be shown to other users, and the original author can also go back and edit their data. I'm looking for the correct way to safely escape this data. I'm only sql sanitizing on the way in, so everything is stored as it reads. Let's say I have "déjà vu" in the database. Or, to be more ...

Implementing escape sequences for a serial devices

Hello everyone! I have a serial device connected to a linux host. The host will be need to be able to process standard AT commands. I need to include the standard AT '+++' escape sequence for a serial device.. I haven't had much luck finding code. Anyone know of any open source libraries or code I can take a look at for the actua...

Escaping &hellip; with BeautifulSoup

I am currrently using BeautifulSoup to scrape some websites, however I have a problem with some specific characters, the code inside UnicodeDammit seems to indicate this (again) are some Microsoft-invented ones. I'm using the newest version of BeautifulSoup(3.0.8.1) as I am still using python2.5 The following code illustrates my proble...

How to suppress quotes output as HTML entities?

$selected = ' selected="selected"' # or $selected = qq( selected="selected") is returned as: selected=&quot;selected&quot; which is an invalid HTML attribute, ofcourse. How do I fix it? Edited to add: <select name="alignment" class="select" <%== param('feature') ? '' : 'disabled'; %> > % foreach (keys %al) { % my $selected...