search-and-replace

Good tutorial + reference for Emacs search and replace?

For a new user of Emacs, are the any good tutorials + references for learning and getting familiar with Emacs's search, replace and regex features? ...

Find First Word matching from Given Text - Regex

I want to find First Word matching from Given Text and replace with another word, using Regex. Consider following string as an Example Text Which type is your item? i suppose that the item isn't a string, if so you can override ToString() method in the item class and use the jayant's code. I want to search first "item" w...

How do I do a search and replace on a configuration file using Wix?

Some code I inherited has its "configuration" (if you can call it that) embedded into its PHP and ASP (don't ask) code. Because its not an XML or INI file, I'm having the darnedest time figuring out how to modify these files at install time. If I could, I'd like to do a simple search and replace. I've read elsewhere (http://stackoverf...

How to remove an entire line which matches a pattern

The following pattern matches an entire line, how do I search and remove these lines. If I leave a space in the replace string, it leaves a blank in that particular line, when I do via eclipse. ^[\t ]*<param name="logic" .*$ ...

How to search for occurences of more than one space between words in a line

How to search for occurences of more than one space between words in a line 1. this is a line containing 2 spaces 2. this is a line containing 3 spaces 3. this is a line containg multiple spaces first second three four All the above are valid matches for this regex. What regex should I use? ...

how to search and replace big chunks of text in files, with VS or with another text editor?

Hello, I have a bunch of old .asp files to refactor, and the first thing I have to do is to replace a bulky <table> wich is repeated in every file (it's a menu) with a server side include. the table has no id, but its container has it: <td id="leftColumn" > <table> manually going through the files and replacing the t...

Python regular expressions: search and replace weirdness

I could really use some help with a Python regular expression problem. You'd expect the result of import re re.sub("s (.*?) s", "no", "this is a string") to be "this is no string", right? But in reality it's "thinotring". The sub function uses the entire pattern as the group to replace, instead of just the group I actually want to r...

GVIM. How to change certain words that match the pattern?

In normal mode I press +* and VIM highlighs the occurences of the word under cursor. How to change for example 2,4-5 (second, fourth and fifth) words in search results with %s command? I know I can use %s and to change the searched word in certain lines, but it is not what I need. ...

Multiline sed option?

I want to remove all the text between (and including) two strings in all the files in a directory. For an example, the files look something like this: flag bla bla bal bla bla bla endflag etc.. This is what I'm doing with sed: sed -i "s:flag.*endflag::m" * However, the 'm' option is not part of sed. All the other Stack Overflow th...

New to Python: Replacing a string by its position in a line

Let's say I got a file with three lines of this structure: foo Black sheep: 500 bar What I'd like to do is an iteration to change "Black sheep: 500" to 600, 700 and so on, replacing the old one. I can think of a way of doing it by search&replace, but I'm looking for a more elegant way by replacing a certain position (here pos.3) withi...

Visual Studio 2008 search and replace regex

I have a large solution with a lot of lines that I need to replace. In Visual Studio, you can search and replace with the aid of regular expressions. I want to replace lines like: rst.Fields("CustomerName").Value rst.Fields("Address").Value rst.Fields("Invoice").Value To: row("CustomerName").ToString() row("Address").ToString() row(...

VIM search and replace - replace string that is found on particular lines only

So I have a bunch of lines like this - $ns duplex-link n1 n2 10mb 10ms DropTail $ns duplex-link-op n1 n2 10mb 10ms queuePos 0.5 $ns duplex-link n2 n3 10mb 10ms DropTail $ns duplex-link-op n2 n3 10mb 10ms queuePos 0.5 $ns duplex-link n3 n4 10mb 10ms DropTail $ns duplex-link-op n3 n4 10mb 10ms queuePos 0.5 Now here's the problem. I wan...

Scripting Vim with find -exec

Hello, I have a little Vim script which does a multi-line search and replace: vim -c 's/^ *<hi a=\"26\">\nHello/<td height=\"26\">\r<\/table>\r<bla \/>' \ -c 'w!' -c 'q' test.html That works. However, when I put that in a find -exec to do this recursively in the directory: find . -iname 'test.html' -exec \ vim -c 's/^ *<hi a=...

Mass Search and Replace with Wildcards or Reg Expression MyString.Length to Len(MyString)

I have a large ASP.NET project where I want to do a mass search and replace (about 3500 instances) I want to change If strErrorMessage.Length > 0 If strSomeString.Length > 0 If strWhatever.Length > 0 and any other similar call to the Length method from a string to the following If Len(strErrorMessage) > 0 If Len(strSomeString) > ...

Oracle: Replacing non-numeric chars in a string

I have a field in my database where users have saved free-form telephone numbers. As a result, the data has all sorts of different formatting: (area) nnn-nnnn, area-nnn-nnnn, area.nnn.nnnn, etc. I would like to strip out all the non-numeric characters and just store the digits, but I can't find a simple way to do this. Is it possible...

XSL: Replacing certain characters with xml tags

This one is a bit tricky, and I've been stuck on it for a bit of time. What I wish to do is put tags in place of brackets '[' (e.g. for buttons, links, etc), and in place of ']' <section> <title>Buttons</title> <orderedlist> <listitem> <para>Clicking on [Save] will attempt to save changes, then it navigates...

Deleting / changing searched text in Vim

When I do an interactive search for some pattern, each time I hit n, I get the next result. How do I delete / change each result that I come to? Ideally, what I'm looking for would work like this: I hit n to get the search result, and then magic command to highlight that result in visual mode, and then I can do d or c to delete or chang...

How can I remove a specific character from a string in Perl?

I'm trying to remove a specific character from a string in Perl: my $string="MATTHATBAT"; substr($string, 2, 1, ''); EDIT: This does work, sorry. Leaving this here in case someone needs to know how to do this. Also, is there a more efficient way of doing this? The string should now be MATHATBAT. Am I missing something? I know tha...

notepad++ regular expressions to convert lines for SPSS syntax editor

Hi People, I am curently busy with bulding a synthax document in SPSS and have a column of variable strings that consists of approximately 40 lines (it will be much much more in coming week). SPSS has a nice way of creating it (can be seen here :) http://vault.hanover.edu/~altermattw/methods/stats/reliable/reliability-1.html) but it can...

Best way to replace chars in a string from a Hashtable?

Hello, i have a method which gets a string and a Hashtable ... the hash contains the char to be replaced in the key and the value which goes instead as value. Whats the best way to check the hash and replace the chars in the string? Thanks :) ...