replace

Using LINQ to SQL and chained Replace

I have a need to replace multiple strings with others in a query from p in dx.Table where p.Field.Replace("A", "a").Replace("B", "b").ToLower() = SomeVar select p Which provides a nice single SQL statement with the relevant REPLACE() sql commands. All good :) I need to do this in a few queries around the application... So i'm lookin...

Visual Studio Find and Replace Variables

I am trying to replace a two letter state abbreviation with text then the abbreviation. Eventually I want to find and replace the rest. How do I capture the value found? .... I tried \1 and {1} AL 32.2679134368897 -86.5251510620117 AR 35.2315113544464 -92.2926173210144 AZ 33.3440766538127 -111.955985217148 CO 39.709863142533...

rails replace path in string

I have a string that may have a path to a file. Example src="/folder/whatever". How do I replace that path with src="http://www.sitename.com/folder/whatever ? ...

Python: Replace string with prefixStringSuffix keeping original case, but ignoring case when searching for match

So what I'm trying to do is replace a string "keyword" with "<b>keyword</b>" in a larger string. Example: myString = "HI there. You should higher that person for the job. Hi hi." keyword = "hi" result I would want would be: result = "<b>HI</b> there. You should higher that person for the job. <b>Hi</b> <b>hi</b>." I will not...

How do I use regex to replace non-word chars in a specific piece of string?

I have text file with a row like this: SendersTimeSeriesIdentification: COMPANY_A/COMPANY_B/REF_7/20090505 I'd like to replace all non-word chars in the value part with the character n, like this: SendersTimeSeriesIdentification: COMPANYnAnCOMPANYnBnREFn7n20090505 But there are similar strings all over the file, which must remain i...

match image tags with regEx

Hi I am having some trouble with this regex: <img(.+)src="_image/([0-9]*)/(.+)/> Global and case insensitive flags is on. The problem is that it also grabs Image n (see string below), but I want it only to match the image tags in the string. <p>Image 1:<img width="199" src="_image/12/label" alt=""/> Image 2: <img width="199" src="...

Javascript multiple replace

How do you replace all instances of one string with another in javascript? Example: someString = 'the cat looks like a cat' anotherString = someString.replace('cat', 'dog'); results in anotherString being set to 'the dog looks like a cat', and I would like it to be 'the dog looks like a dog' ...

[DB2] Problem with Replace Function

Hello! :-) In one of my resultsets i have column with char - data. I want to create another column, which carries altered data from the first column. There i want to exchange all 'ö' with oe. I tried it like this: Select NAME1, case when POSSTR(NAME1, 'ö') is not null then REPLACE(NAME1, 'ö', 'oe') end As __NAME1 from xyz; ...

Trying to replace html tags using regex

For the example, I'm trying to replace <script type='text/javascript'>some stuff</script> with: <div type='text/javascript'>some stuff</div> I'm currently testing with: alert( o.replace( /(?:<\s*\/?\s*)(script)(?:\s*([^>]*)?\s*>)/gi ,'div') ); But what I'm getting is: divsomestuffdiv How can I get this to only replace the "sc...

Perform JavaScript .replace in JQuery

How would I perform the following in JQuery? var elmOperator = document.getElementById(elm.id.replace('Include', 'Operator')); The ID that is being manipulated would look something like Criteria[0].Include. I am trying to create a variable for a related ID which is Criteria[0].Operator. Thanks in advance! ...

How do I replace part of string using regexp?

HI, I have a string that looks like /dir/dir1/filename.txt I want to replace the "filename.txt" with some other name leaving the "/dir/dir1" intact so after the replace the string would look like /dir/dir1/newfilename.txt how would I do that using RegExp in Perl considering that I don't know the value of "filename" Many Thanks...

Replace a number in Netbeans editor with incrementing number

Hello to all I have some code in Netbeans 6.1 editor that looks like this fooString(8) fooString(8) fooString(8) fooString(8) foostring2(8) foostring3(8) foostring4(8) foostring5(8) foostring6(8) foostring7(8) foostring7(9) foostring7(10) foostring7(11) foostring7(12) and i want to convert it to fooString(1...

What is the BEST way to replace text in a File using C# / .NET?

I have a text file that is being written to as part of a very large data extract. The first line of the text file is the number of "accounts" extracted. Because of the nature of this extract, that number is not known until the very end of the process, but the file can be large (a few hundred megs). What is the BEST way in C# / .NET to ...

Replace multiple instances in select statement

User SQLServer 2005 Here is an example of string I'm stuck with: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial Rounded MT Bold;}{\f1\fnil\fcharset0 Arial;}} \viewkind4\uc1\pard\f0\fs54 1000\f1\fs20\par } I want to replace any font name with 'Times New Roman' I can get the first one with (textlong1 is ...

Can you replace or update an SQL constraint?

I have written the following constraint for a column I've called 'grade': CONSTRAINT gradeRule CHECK grade IN (‘easy’, ‘moderate’, ‘difficult’), Is it possible to later update the gradeRule to have different values? For example, 'moderate' and 'difficult' could be changed to 'medium' and 'hard'. Thanks ...

vim & csv file: put header info into a new column

I have a large number of csv files that look like this below: xxxxxxxx xxxxx Shipment,YD564n xxxxxxxxx xxxxx 1,RR1760 2,HI3503 3,HI4084 4,HI1824 I need to make them look like the following: xxxxxxxx xxxxx Shipment,YD564n xxxxxxxxx xxxxx YD564n,1,RR1760 YD564n,2,HI3503 YD564n,3,HI4084 YD564n,4,HI1824 YD564n is a sh...

Replace block of text in vs2008

Hi All, is there any way how to replace block of text (multi-line) in VS2008(VS2005)? So far I know VS2008 supports only single line replacing. Any tips welcome, cheers X. EDIT: thanks for tips guys. I was rather looking for some simplier option: like select multiline text, click Ctrl+H, Ctrl+V (copy text from memory) and hit Repla...

How might I perform conditional replacement using JavaScript's RegExp?

I am trying to wrap my head around using regular expressions and replace() with JavaScript, but have not yet been successful Suppose I have a string containing this: <img alt="a picture of ..." src="image/1533?foo=1&bar=2$zot=3" width="500" /> If zot=3 I want remove foo (and its value) (or replace foo=x with an empty string). The re...

Replacing an element and returning the new one in jQuery

Hi, How do you replace an element in jQuery and have the replacement element returned instead of the element that was removed? I have the following scenario. I have many checkboxes and once you click one of them, that checkbox is replaced by a loading icon. Once some AJAX stuff happens, the loading icon is replaced by a tick icon. Usi...

Regexp for cleaning the empty, unnecessary HTML tags

I'm using TinyMCE (WYSIWYG) as the default editor in one of my projects and sometimes it automatically adds <p>&nbsp;</p> , <p> </p> or divs. I have been searching but I couldn't really find a good way of cleaning any empty tags with regex. The code I've tried to used is, $pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/"; $str = preg_replace(...