replace

Parallel gsub: how does one remove a different string in each element of a vector

I have a guest list that has a last name in one column and then in another column I have the first names or the full names (first space last) of each person in the family. I am wanting to get the other column to just have the first names. gsub(guest.w$Last.Name,"",guest.w$Party.Name.s.) That would work perfectly if I just had one row...

How to replace elements of unknown content and length in strings in Java?

I need help with replacing segments of a string in Java. I have tried both the String method 'replace' and StringTokenizer. As the segments of my strings is of unknown length I guess StringTokenizer is out of question. I also need to go through several strings (with many similar segments to replace in each string). I have assumed there ...

C# String.Replace with a start/index (Added my (slow) implementation)

I'd like an efficient method that would work something like this EDIT: Sorry I didn't put what I'd tried before. I updated the example now. // Method signature, Only replaces first instance or how many are specified in max public int MyReplace(ref string source,string org, string replace, int start, int max) { int ret = 0; in...

python search replace using wildcards

hi somewhat confused.. but trying to do a search/repace using wildcards if i have something like: <blah.... ssf ff> <bl.... ssf dfggg ff> <b.... ssf ghhjj fhf> and i want to replace all of the above strings with say, <hh >t any thoughts/comments on how this can be accomplished? thanks update (thanks for the co...

How to search and replace a tag value in xml file using delphi?

How to search and replace a tag value in XML file using Delphi? I know what the XML tag is, but the value is random and simply needs to be reset to a default value, so in reality I cannot/should not search for the value but only the tag. I also know the location of the file/files. I'm new to Delphi, can someone provide me a simply exam...

Replace link location (jQuery)

<a href="http://www.google.com"&gt;link&lt;/a&gt; How do I replace link location from google.com to say "#"? $('a').attr( 'href', '#' ); isn't working. ...

PHP regex replace white space by &nbsp; if it is following single letter

Hi, I have user defined string (html formated string to be saved and used in web) and need to find a way to replace each white space which is right after a single letter by &nbsp;. For example "this is a string" should become "this is a&nbsp;string", "bla bla b l abla b la blabla" should become "bla bla b&nbsp;l&nbsp;abla b&nbsp;la b...

jQuery - manipulate dropped element in sortable list

Hi there, I have a draggable list (.field) where you can drag & drop items from it into a sortable list (.sortlist). I did it this way because I didn't want the master list (.field) altered in any way. It works fine, except I cannot work out how to manipulate the dropped field in a sortable list. I can do it from a draggable into a dr...

XSLT multiple replacing

I have an XML document, something like <root> <item>_x0034_SOME TEXT</item> <item>SOME_x0020_TEXT</item> <item>SOME_x0020_TEXT_x0032_</item> </root> I'm exporting it to HTML, but I have problems replacing escape characters. I have found several templates in the web to do text replacing but they all are similar to this: <xsl:tem...

Find and Replace

I have a table that I screen scraped using the jQuery load function, the function returns a table with text and graphics. The website I scraped from uses relative paths for their images so when I return the code to my page the images are not showing up. I have been looking for a jQuery function to find the tag and either update it to ad...

Retain case when using str_ireplace?

I am building a search that will wrap the searched text with a <span> tag and i have this code working ok: str_ireplace($q,'<span>'.$q.'</span>',$row[name]); The problem is, if a user searches for Tom is will show Tom which is cool, but if they put in tom because of the str_ireplace it would show tom, does that make sense? The real is...

Replace & to &amp; in URLs

I have TONS of XML Parsing Error: EntityRef: expecting ';' errors on my page only because of the incorrect use ampersands in links by the developer. Instead of asking him to use &amp; instead of &, how can I replace those after page load using jQuery? Edit: Ah right, validators read the source so it won't work. Is there any other way ...

jquery .replaceWith() not playing nice with .clone() in IE7

I'm using jQuery to created a linked TOC that appears in a dialog box. The function I wrote to do so finds all the h4's in the page and gives them ids to link to adds some numbering display info clones them turns the clones into lis wraps the inner text in anchor tags finds the anchors adds a click function to the anchors to close...

jQuery how to replace src url

I have a page that I screen scraped, the scraped page used a relative path for their images and when I load my page, the url of my site is being inserted on the src attr. I need to find some way of replacing my url with the url of the remote site in order for the images and other items that reference it to show up properly on my page. ...

Change label based on element visibility (jQuery)

HTML: <a href="#">Show next element</a> <div>content</div> jQuery: $('a').toggle(function () { $(this).next().show(); }, function () { $(this).next().hide(); }); How do I change the above jQuery so it also changes the "Show" in the link to "Hide" when the element is visible? Thanks! ...

replace ntext (more than 4000 characters) in sql server 2000

How to replace text in sql server 2000 in a ntext column with more than 4000 characters? conversion to nvarchar(max) does not work as it truncates values. ...

How can I replace < and > in the content of xml file using regex?

How can i replace a "<" and a ">" (in the content of xml file) with a matching "&lt;" and "&gt;" (with a pre known set of tags) using a regex? example: <abc>fd<jkh</abc><def>e>e</def> should result with: <abc>fd&lt;jkh</abc><def>e&lt;e</def> it must be done with a regex! (no xml load and such...) ...

replacing an undefined tags inside an xml string using a regex.

Hi! i need to replace an undefined tags inside an xml string. example: <abc> <>sdfsd <dfsdf></abc><def><movie></def> (only <abc> and <def> are defined) should result with: <abc> &lt;&gt;sdfsd &lt;dfsdf&gt;</abc><def>&lt;movie&gt;<def> <> and <dfsdf> are not predefined as and and does not have a closing tag. it must be done with a r...

Matching one-line JavaScript comments (//) with re

I'd like to filter out (mostly one-line) comments from (mostly valid) JavaScript using python's re module. For example: // this is a comment var x = 2 // and this is a comment too var url = "http://www.google.com/" // and "this" too url += 'but // this is not a comment' // however this one is url += 'this "is not a comment' + " and ' ne...

How can I rewrite URLs except those of a particular domain?

Hi. Can you please help me to make perl regexp to replace (http://.+) to http://www.my1.com/redir?$1 but do nothing for urls like http://www.my1.com/ or http://my1.com/ For instance I need to replace http://whole.url.site.com/foo.htm to http://www.my1.com/redir?http://whole.url.site.com/foo.htm http://www.google.com to http://www.my1.co...