replace

How to replace last occurrence of characters in a string using javascript

Hi I'm having a problem finding out how to replace the last ', ' in a string with ' and ': Having this string: test1, test2, test3 and I want to end out with: test1, test2 and test3 I'm trying something like this: var dialog = 'test1, test2, test3'; dialog = dialog.replace(new RegExp(', /g').lastIndex, ' and '); but it's not w...

How do I replace a string that starts with "[id", has an unknown middle part and ends in "]"?

Hello. I would like to replace strings that starts with "[id", has a middle part unknown and ends in "]" in a $text. I know how to replace strings that starts with "[id" and ends with "]" but I can't figure out how to include the unknown middle body part as a rule of replace. Any ideas how to replace like this ? Thanks. ...

Replacing input fields from select choices (dropdown menu) with javascript

Three things: select box 1, input box, select box 2. Based on the selections in select box 1 (drop down list 1), I want either input box to be visible or select box 2 to be visible, but not both. Any help would be great :) I am populating the options in select box 2 based on the choice in select box 1, but sometimes the user's choice ...

Vim: Replace selection with default buffer without overwriting the buffer.

Here is my problem: I am in visual mode. I select text and copy it to the buffer. ((y)ank) I select another text which I want to replace and paste the buffer. ((p)aste) Now the second selection has been replaced in the buffer, however I want the first one to still sit in there. Any ideas? ...

How can I replace characters just at the end of a string in Perl?

I have a Perl script that replaces any Us or Ns at the end of a string with Ts. This program is what I'm trying: use strict; my $v = "UUUUUCCNNCCCCNNNCUUUNNNNN"; printf("before: %s \n", $v); if($v =~ m/([UN]+)$/) { my $length = length($1); substr($v, (length($v) - $length), $length) = "T" x $length; } printf(" after: %s \n", $v); ...

Java's String.replace() vs. String.replaceFirst() vs. homebrew

I have a class that is doing a lot of text processing. For each string, which is anywhere from 100->2000 characters long, I am performing 30 different string replacements. Example: string modified; for(int i = 0; i < num_strings; i++){ modified = runReplacements(strs[i]); //do stuff } public runReplacements(String str){ str = str....

replace the unknown value using php

In my project am using some post, in that post i got a error in browser like this, "fourth � one - hai" => i paste that error, but i cant get in, Its like a square between fourth and one... But i dont know that issue, and also i cant string replace that value, and i try to attach the screenshot, that also not working... And if u wan...

Replace Appended text with new text on Click

With jquery I am adding a div and appending the text "click to view" when the div is showin I would like to change that text to "click to close" Right now I have $('#toggle_template') .css('cursor','pointer') .append(' (click to view)') .click(function(){$('#template').toggle(500); $('#toggle_template').find(' ...

Replace a string on php

Hi All, I am using a function that converts INR to USD. I am using this function: function convertCurrency($from_Currency,$to_Currency,$amount) { $amount = urlencode($amount); $from_Currency = urlencode($from_Currency); $to_Currency = urlencode($to_Currency); $url = "http://www.google.com/ig/calculat...

ASP.net c# replace string not working

// Build email link confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode; using (SqlCommand cmd = new SqlCommand("SELECT newRegEmailBody, newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)", Master.cn)) { SqlDataReader rdr = cmd.Exec...

jQuery - Scrub data in all textboxes/textareas in a form?

My buddy at work told me that you could use jQuery to write a few lines of code that would find a single character (in this example '\0') and replace it for all textboxes and textareas on the page. Of course, he didn't tell what lines of code would do that ... Is there a simple way to do this? We have a problem of people copying data ...

How To I Replace New Elements Added To A Page With Jquery

Here is the scenario... I have a a checkbox next to each field that I am replacing on page load with jquery with "Delete" text that enables me to delete the field via jquery, which is working fine. Like so... $(".profile-status-box").each(function(){ $(this).replaceWith('<span class="delete">' + 'Delete' + '</span>') }); The problem...

trying to replace "\" char using javascript for a json parser

so I have the following line of javascript: YAHOO.lang.JSON.parse(txt) where text is a string that is pulled from the database. This is an example of one of the problem strings I'm getting back: 5000\25\30% The JSON parser is throwing syntax errors on the / character as far as I can tell. I looked through threads here and most of t...

How to change specific text of mutiple classes

Hi there, I'm cloning a fieldset and incrementing the attribute names as a new clone is created. However I want the same to happen if I delete I clone so that any cloned fieldset after the deleted will fill in the gaps. As in, if the 2nd clone is deleted, the 3rd with be renamed as the 2nd etc. I'm trying to change a the classes and ID...

JS String.replace can be tempremental with Safari

The Backstory: This works fine in all browsers EXCEPT Safair (5.0.1) var chunk = arr[i]; chunk = chunk.replace('$', '\\$'); var a = eval('message.match(/' + chunk + '/gi);'); if(a instanceof Array) symbol = symbol.concat(a); So I modified it to the following: var chunk = String(arr[i]); chunk = chunk.replace('$', '\\$'); var a = eva...

<a name="whatever"></a> deprecated Batch convert to id

I have a lot of old html files that I need to update. Hopefully, not manually. I can use a find/replace app to go through a directory and find all with <a name= and replace it <span id= since "name" is deprecated. How would I then find all of the correct endtags and convert </a> to </span> without ruining all hyperlinks? TIA, Linda ...

Remove entire word if the word contains specific string

I would like to do the following, preferably with PHP: Remove an entire word if a part of the word contains a specific string. This should be case insensitive and work multiple times, e.g. on a large text. Pseudo-code: match = "www." lots_of_random_text = "... hello and welcome to www.stackoverflow.com! blah blah" result = magic_functi...

How I can replace it

I has a string $text =<<<HTML <div align="center"><center><img src='http://ecx.images-amazon.com/images/I/41KZa6thzcL._SS500_.jpg' alt="The Birthday of the World: And Other Stories"/></center><br/> thanks all "coder". </div> HTML; I want replace all " from tag with \" or ' with \' and don't replace if " or ' not in tag and r...

PHP replace variables in Word document

Hello everyone I have a word document that contains certain variables (for example the string $$title$$). Now I want to open this word document in PHP and replace the string $$title$$ with a string I read out of the database. Final step would be to save this word document and give it to the user for download. Replacing the string and s...

mysql complex update and replace

Hey everyone, I've got an interesting query that I wonder if anyone can help with? Basically, I have three tables, Title, Attribute and Attribute_Value Title contains a list of templates like 'Created on {Date} by {User} in {Category}' then in the Attribute table, I have rows that contain a definition of the parameters wrapped in cur...