replace

Replacing multiple occurrences in nested arrays

I've got this python dictionary "mydict", containing arrays, here's what it looks like : mydict = dict( one=['foo', 'bar', 'foobar', 'barfoo', 'example'], two=['bar', 'example', 'foobar'], three=['foo', 'example']) i'd like to replace all the occurrences of "example" by "someotherword". While I can already think of a f...

Regular expression replace a word by a link

I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link. Example: i'm living <a href="Paris" atl="Paris link">in Paris</a>, near Paris <a href="gare">Gare du Nord</a>, i love Paris. would become i'm living.........near <a href="">Paris</a>..........i ...

Case insensitive string replacement in JavaScript?

I need to highlight, case insensitively, given keywords in a JavaScript string. For example: highlight("foobar Foo bar FOO", "foo") should return "<b>foo</b>bar <b>Foo</b> bar <b>FOO</b>" I need the code to work for any keyword, and therefore using a hardcoded regular expression like /foo/i is not a sufficient solution. What is the...

Smarty replace text with double quotes

I have the following string in the smarty (php templating system) variable $test: <img height="113" width="150" alt="Sunset" src="/test.jpg"/> I want to add "em" to the height and width like this: {$test|replace:'" w':'em" w'|replace:'" a':'em" a'} But this doesn't work... What's the problem and the solution? ...

How do I replace 'php3' with 'php' inside every file in a directory.

Hopefully a nice simple one. I've got a php3 website that I want to run on php 5.2 To start with I'd just like to have every reference to the current "index.php3" _within_each_file_ (recursively) changed to "index.php" and then move on to worrying about globals etc. K. Go! :) Update: Thanks a lot! I realise that my question missed ...

how to clear or replace a cached image

I know there are many ways to prevent image caching (such as via META tags), as well as a few nice tricks to ensure that the current version of an image is shown with every page load (such as image.jpg?x=timestamp), but is there any way to actually clear or replace an image in the browsers cache so that neither of the methods above are n...

How to change diacritic characters to non-diacritic ones

Hello, I've found a answer how to remove diacritic characters on stackoverflow, but could you please tell me if it is possible to change diacritic characters to non-diacritic ones? Oh.. and I think about .NET (or other if not possible) kind regards ...

How do I implement client side replacement with Javascript?

I have a HTML page with which I want to do some client side replacement using Javascript. The values I would like to replace are in an array like so: var searchFor = new Object(); var replaceWith = new Object(); searchFor = [ "quick", "brown", "fox", ]; replaceWith = [ "nimble", "black", "cat", ]; So every instance of 'brown' s...

How to increment a number in several files if the number is not always the same ?

Hi, I have several files containing this line Release: X I want to increment X in all the files. If X was constant between the files, I could have a bash script looping around the files and doing ($1 containing the former release number and $2 the new one, ie. $1 + 1) : sed 's/Release: '$1'/Release: '$2'/' <$file >$file.new Now,...

How can I search and replace in a PDF document using Perl?

Does anyone know of a free Perl program (command line preferable), module, or anyway to search and replace text in a PDF file without using it like an editor. Basically I want to write a program (in Perl preferably) to automate replacing certain words (e.g. our old address) in a few hundred PDF files. I could use any program that suppor...

C# - String.Replace() but replace only the first match

Closed as a duplicate of How do I replace a string in .NET? I need to replace a sequence in a string, but only once. Part 1: What is the easiest way to do this in C#? Part 2: What is the most efficient way to do this in C#? Bonus points if they're both the same :D (not really, but I'll give you a cookie) ...

Textmate Regex Find Replace Help

Hi, I've got a project I'm working on converting some legacy perl cgi forms to PHP. A lot of this requires finding / replacing information. In one such case, I have lines like this in the perl script: <INPUT type="radio" name="trade" value="1" $checked{trade}->{1}> which needs to read: <INPUT type="radio" name="trade" value="1" ...

[bash] Fill placeholders in file in single pass

I have a skeleton text file with placeholder strings: blah blah blah blah $PLACEHOLDER_1$ blah $PLACEHOLDER_2$ and so on. Specific "form" of placeholders does not matter -- I may change them to whatever most comfortable for specific implementation. I have a bash script where I know values for placeholders, and I need to generate a ne...

HTML special code to ASCII

Hey, is there any built in functions or something like that in php that will allow me to turn HTML special code like: <(;), >(;), Á(;) and ©(;) etc... into <, >, Á and © Lets say I have the value: $fileName = "Gibt es eine schö(;)ne Offroadstrecke? (;)"; And I want this: $fileName = "Gibt es eine schöne Offroadstrecke? "; Any eas...

How can I search for a varying string in an XML file using VBS and replace it with another string

I have a configuration XML file which contains an encrypted password. From time to time we need to reset this password, and the methodology for doing so involves stripping out the string which is effectively the password from the XML file and saving the file. The process also involves stopping and restarting a couple of services which ...

regex implementation to replace group with its lowercase version

Is there any implementation of regex that allow to replace group in regex with lowercase version of it? ...

C# Replace with Callback Function like in AS3

In AS3 you have a function on a string with this signature: function replace(pattern:*, repl:Object):String The repl:Object can also specify a function. If you specify a function, the string returned by the function is inserted in place of the matching content. Also, is it possible to get the the original string in which I want to re...

VB.NET replace whitespace between HTML tags

Is there any way in VB.NET to remove all of the whitespaces between tags in HTML? Say, I've got this: <tr> <td> The string I've built is an entire HTML document, and it counts everything before those tags as legitimate space, so I need to trim it out. Is there a reg ex or function out there I could use to do this? Thanks ...

Replace particular text after the page is loaded with jquery

Is it possible to replace exact text with other text after the page has loaded with jquery? For example, my data is being generated dynamically within a php loop. Once it finishes outputting the information, I'd like to do a find and replace, replacing the phrase "test phrase 1" with "test phrase 2" throughout the page. Is this possibl...

Can anyone explain this .ASP aka VB "Regex.Replace" function so that I can do it in PHP?

Hi, The following code is visual basic, .NET, ASP... all of the above? Can anybody tell me what these two "Regex.Replace" functions/methods will leave me with when "strCookies" is equal to the block of text below the two Regex.Replace functions? I believe the idea is simply to capture the "sessionid" code and then the "cadata" code with ...