substitute

In Ruby, how do I replace the question mark character in a string?

In Ruby, I have: require 'uri' foo = "et tu, brutus?" bar = URI.encode(foo) # => "et%20tu,%20brutus?" I'm trying to get bar to equal "et%20tu,%20brutus%3f" ("?" replaced with "%3F") When I try to add this: bar["?"] = "%3f" the "?" matches everything, and I get => "%3f" I've tried bar["\?"] bar['?'] bar["/[?]"] bar["/[\?]"...

Single sed command for multiple substitutions?

I use sed to substitute text in files. I want to give sed a file which contains all the strings to be searched and replaced in a given file. It goes over .h and .cpp files. In each file it searches for file names which are included in it. If found, it substitutes for example "a.h" with "<a.h>" (without the quotes). The script is this: ...

Java workaround for BigInteger

I was working on a scenario wherein i had to implement BODMAS in Java and the operands could have as many as 1000 digits. So i chose to implement it in the following manner - I converted the infix expression (expression on which BODMAS was to be implemented) to postfix And then i evaluated the postfix expression by parsing every BigInt...

has any method like substitute of mootools in jquery ..

this is mootools code: var myString = "{subject} is {property_1} and {property_2}."; var myObject = {subject: 'Jack Bauer', property_1: 'our lord', property_2: 'savior'}; myString.substitute(myObject); and does jquery has this mothod? or like this method ? ...

How can I get the mapi system stub dll to pass extended mapi calls to my dll?

For various reasons (questioning the reasons is not helpful to me), I'd like to implement my own extended mapi dll for windows xp. I have a skeleton dll now, just a few entrypoints exist for testing, but the system mapi stub (c:\windows\system32\mapi32.dll, I've checked that it's identical to mapistub.dll) will not pass through calls t...

What is the simplest way (or simplest library) to create a truly secure php mail() function?

The mail() function is bad, because it is so permissive with headers that you pretty much can't use it with any user input without subjecting yourself or others to spam. So what is the simplest substitute that can still ensure that it's use is secure? Ideally something that can be included in an external file. ...

Vim: search and replace across multiple lines with conversion to lower case

Hi! Here's what I'd like to do, for each one of many files: search for all occurrences of "<a href" then begin block selection select until the first occurrence of ">" convert the entire match to lowercase Thanks again, Olivier Pons ...

select row from table and substitute a field with one from another column if it exists

I'm trying construct a PostgreSQL query that does the following but so far my efforts have been in vain. Problem: There are two tables: A and B. I'd like to select all columns from table A (having columns: id, name, description) and substitute the "A.name" column with the value of the column "B.title" from table B (having columns: id, t...

R warning message on recursive expression: If you fail, try, try again...

I want to create a function that will retry an expression if it fails. Here's my working version: retry <- function(.FUN, max.attempts=3, sleep.seconds=1) { x <- NULL if(max.attempts > 0) { f <- substitute(.FUN) x <- try(eval(f)) if(class(x) == "try-error") { Sys.sleep(sleep.seconds) return(suppressWarnings(...

Can this be done faster (read file, substitute [sed], write new file)

I use this piece of code in my bash script to read a file containing several hex strings, do some substitution and then write it to a new file. It takes about 30 minutes for about 300 Mb.I'm wondering if this can be done faster ? sed 's,[0-9A-Z]\{2\},\\\\x&,g' ${in_file} | while read line; do printf "%b" ${line} >> ${out_file} printf ...

vim string substitution

Hi, I want to substitute all cygdrive/e with cygdrive/d using vim. But I can't get the matching pattern correctly. Here is my command: s/cygdrive\/e/cygdrive\/d/g it doesn't work. Can anybody show me what is wrong? Thanks, ...

How to write a group of substitude (la->lb), (lb->lc), (lc->la) as a regular expression

I need to do it in vim (MacVim) and use it in one line. z.a2=cross(z.b, z.c)(z.b1, z.c1); became z.b2=cross(z.c, z.a)(z.c1, z.a1); Thank yo ...