replace

Django store regular expression in DB which then gets evaluated on page

Hi, I want to store a number of url patterns in my django model which a user can provide parameters to which will create a url. For example I might store these 3 urls in my db where %s is the variable parameter provided by the user: www.thisissomewebsite.com?param=%s www.anotherurl/%s/ www.lastexample.co.uk?param1=%s&fixedparam=2 A...

VIM Replace word with contents of paste buffer?

I need to do a bunch of word replacements in a file and want to do it with a vi command, not an EX command such as :%s///g. I know that this is the typical way one replaces the word at the current cursor position: cw<text><esc> but is there a way to do this with the contents of the unnamed register as the replacement text and without ove...

Java/Groovy File IO Replacing an Image File with it's own Contents - Why Does This Work?

I have some JPG files that need to be replaced at runtime with a JFIF standardized version of themselves (we are using a vendor that gives us JPG that do not have proper headers so they don't work in certain applications)... I am able to create a new file from the existing image, then get a buffered image from that file and write the con...

Javascript and backslashes replace

here is my string: var str = "This is my \string"; This is my code: var replaced = str.replace("/\\/", "\\\\"); I can't get my output to be: "This is my \\string" I have tried every combination I can think of for the regular expression and the replacement value. Any help is appreciated! ...

Replacing backslash with another symbol in PHP

Hi there, Been struggling with replacing a backslash by another symbol such as '.-.' just to indicate the position of backslashes as I could not send a string such as 'C\xampp\etc.' through url as GET variable so I thought I'd first replace the backslashes in that string by another symbol, then send through url, and then replace them ba...

How to detect and replace non-printable characters in a string using Java ?

For instance I have a string like this : abc123[*]xyz[#]098[~]f9e [*] , [#] and [~] represents 3 different non-printable characters. How can I replace them with "X" in Java ? Frank ...

Convert URLs into HTML links using sed?

I'm wondering if it's possible (recommended might be the better word) to use sed to convert URLs into HTML hyperlinks in a document. Therefore, it would look for things like: http://something.com And replace them with <a href="http://something.com"&gt;http://something.com&lt;/a&gt; Any thoughts? Could the same also be done for emai...

Replace occurences of NSString - iPhone

Hi everyone, I have a long NSString in which I m trying to replace special characters. Part of my string looks like this: "veau (c\u00f4telette)","veau (filet)","agneau (gigot)","agneau (c\u00f4telette)","b*\u0153*uf (hach\u00e9)","porc (hach\u00e9)" I would like to replace all the \u0153 with "oe". I ve tried: [response stringByRepla...

useing my own db $info to replace parts of a url and open in a iframe

this dont work any options please? "Result below if printed" http://maps.google.com/maps/api/staticmap?center=WYOMING,WYOMING,MI&amp;zoom=14&amp;size=500x500&amp;maptype=roadmap&amp;markers=color:blue|label:S|42.902160,-85.696708&amp;sensor=false need to replace parts of url like shown above to enter "result" into an iframe src= ???...

Replace text with other text in the same line

I don't know if I can use regex for this, but I want to replace something in this xml: <custom-attribute name="Attribute_1" dt:dt="string">Danny Boyle</custom-attribute> <custom-attribute name="DVD-releasedatum" dt:dt="string">06/10/1999</custom-attribute> should become <Attribute_1>Danny Boyle</Attribute_1> <DVD-releasedatum>06/10/1...

Will MySQL InnoDB ON UPDATE CASCADE constraints update properly during a MySQL REPLACE command?

If I have table B with foreign key references to table A (set to ON UPDATE CASCADE) and I run a LOAD DATA INFILE file.txt REPLACE INTO TABLE A; command, will the references update properly? Please note that I'm not talking about ON DELETE CASCADE; I know a REPLACE command will delete records in table B if I have that set. ...

Java String Replace and null characters

Testing out someone elses code (of course it was ...) , I noticed a few JSP pages printing funky non-ascii characters. Taking a dip into the source I found this tidbit. // remove any periods from first name e.g. Mr. John --> Mr John firstName = firstName.trim().replace('.','\0'); Does replacing a character in a String with a null ch...

JavaScript replace()

I'm trying to use the replace function in JavaScript and have a question. strNewDdlVolCannRegion = strNewDdlVolCannRegion.replace(/_existing_0/gi, "_existing_" + "newCounter"); That works. But I need to have the "0" be a variable. I've tried: _ + myVariable +/gi and also tried _ + 'myVariable' + /gi Could someone lend a hand ...

Replace a whole line in a txt file

I'am new to Python 3 and could really use a little help. I have a txt file containing: InstallPrompt= DisplayLicense= FinishMessage= TargetName=D:\somewhere FriendlyName=something I have a python script that in the end, should change just two lines to: TargetName=D:\new FriendlyName=Big Could anyone help me, please? I have tri...

regexp uppercase to lowercase

Hi, is it possible to transform regexp pattern match to lowercase? var pattern:RegExp; var str:String = "HI guys"; pattern = /([A-Z]+)/g; str = str.replace(pattern, thisShouldBeLowerCase); Output should look like this: "hi guys" Thx ...

String replace in j2me/javeme double space

How can I replace this "a  b" by "a b" in j2me? the replace() method doesn't accept Strings, but only chars. And since a double space contains two chars, I think i have a small problem. ...

How to replace the Last "s" with "" in PHP

Hi, I need to know how I can replace the last "s" from a string with "" Let's say I have a string like testers and the output should be tester. It should just replace the last "s" and not every "s" in a string how can I do that in PHP? ...

postgres - regex_replace in distinct clause?

Ok... changing the question here... I'm getting an error when I try this: SELECT COUNT ( DISTINCT mid, regexp_replace(na_fname, '\\s*', '', 'g'), regexp_replace(na_lname, '\\s*', '', 'g')) FROM masterfile; Is it possible to use regexp in a distinct clause like this? The error is this: WARNING: nonstandard use of \\ in a string lit...

Using SDL to replace colors using SDL Color Keys

Hey, I am working an a simple Roguelike game, and using SDL as the display. The Graphics for the game is an image of Codepage 437, with the background being black, and the font white. Instead of using many seperate image files that are already colored, I want to use one image file, and replace the colors when it is being loaded into m...

C# - How do find a string within a string even if it spans across whitespace?

I want to be able to find and highlight a string within a string BUT I no not want to remove the space. So if my original string is : There are 12 monkeys I want to find '12 mon' and highlight those characters ending up with : There are < font color='red' >12 mon< /font >keys BUT I also want the same result if I search for '12mon' ...