EzDevInfo.com

find-and-replace interview questions

Top find-and-replace frequently asked interview questions

vim delete all lines that do NOT contain a certain word

In vim I can delete all lines that contain the word "price" with this

:g /price/d

How can I delete all lines that do NOT contain the word "price"?


Source: (StackOverflow)

How to find and replace the character "*" in Excel

I am trying to find and replace the * (star, or shift+8) character in a bunch of formulas in Excel 2007. * of course matches the ENTIRE contents of the cell, which is not what I want. How do I disable this behavior?


Source: (StackOverflow)

Advertisements

How can I do a recursive find and replace from the command line?

Using a shell like bash or zshell, how can I do a recursive 'find and replace'? In other words, I want to replace every occurrence of 'foo' with 'bar' in all files in this directory and its subdirectories.


Source: (StackOverflow)

Search and replace with TAB character in Sublime Text 2

In Sublime Text 2, I want search and replace by the TAB character.

I tried replacing with \t char but it's not working.

How can I do it?


Source: (StackOverflow)

How to remove this symbol "^@" with vim?

I have some files that are corrupted with this symbol:

^@

It's not part of the string; it's not searchable. How do I substitute this symbol with nothing, or how do I delete this symbol?

Here is an example line from one file:

^@F^@i^@l^@e^@n^@a^@m^@e^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@:^@ ^@^M^@

Source: (StackOverflow)

Find and replace in Notepad++ using wildcards/regex

I have a SQL dump with expressions such as youtubehd:2nj6bykw. The 2nj6bykw can also be a different random string. It is always 8 characters long.

I want to replace youtubehd:2nj6bykw with just youtubehd.

How can I do this without replacing it manually, one by one? The SQL dump is over 230000 lines long and has about 200 occurrences of these strings.

I suppose I need a wildcard, but I have no clue about what it is and how I can do this.


Source: (StackOverflow)

Use Notepad++ to change under_score_case to CamelCase?

I can write a regular expression in NP++ to find under_score_case. I can use TextFX in NP++ to change case to upper and lower case by highlighting and selecting.

How can I use either NP++'s Find/Replace or TextFX's find and replace to stitch these together and convert under_score_case to camelCase?

I want to learn how to do this in NP++ not use a script.

Sample input:

this is_a_line
some more_data_over_here
whoop de_do_da

Desired output:

this isALine
some moreDataOverHere
whoop deDoDa

The regex to match the underscores would be _([a-z]). The replacement that I think exists, but I cannot find is something like _\toupper\1 .


Source: (StackOverflow)

How do I delete lines without "." in Notepad++? [duplicate]

This question already has an answer here:

In Notepad++, I have many lines in the format:

abc.xyz

where "abc" might have space or - or numbers.

How do I delete lines without "."? So if a line does not have any ".", I want it removed completely, not even leave an empty line.


Source: (StackOverflow)

Find and Replace several several different values all at once

I have a file with multiple instances of Text_1 and Text1 and I need to replace both those strings with Text_A and TextB respectively.

Currently I'm doing two Find and Replace functions on each file one that finds Text_1 and replaces it with Text_A and the other that finds Text1 and replaces it with TextB.

Is there any way to do this all at once instead of having to run "Find and Replace" twice?

I am using Dreamweaver CS3, but I also have Notepad++, regular Notepad, OO Writer, MS Word if those will be easier. Ideally I could do this in Dreamweaver or Notepad++ but I'm open to downloading something else to get the job done. I'd prefer not to have to do any command line stuff or create a batch file (while I'm aware of it, I don't understand it really).

Edit:

In case the above description isn't clear, let me explain it this way...

I want to run Find & Replace 1 time in 1 document and I want it to do ALL of the following during that one Find & Replace instance:

  1. Find: Text_1 and Replace with: Text_A
  2. Find: Text1 and Replace with: TextB

I am not trying to do a Find and Replace across several documents.


Source: (StackOverflow)

How to "demote" all titles and headings in Word 2010?

I built a large help document for an application I wrote. I used all the default styles in Word 2010, including "Title", "Heading 1", "Heading 2", etc. Sadly, when I generated the Table of Contents, Titles were not included. I'm also now using chmProcessor to automatically generate a website from the document, and it's not including Titles in its Table of Contents either.

I'd like to make all Titles into Heading 1s, all Heading 1s into Heading 2s, and Heading 2s into Heading 3s, etc. Is this possible without a huge manual effort? (I'm sure there's a better word than "demote" for this.)


Source: (StackOverflow)

Notepad++ Delete Lines with Find & Replace

Does anyone know how to delete a line using Find & Replace in Notepad++ ?

In my Find query it finds the proper lines okay: ^.pPrev.$ In the Replace field, I leave it blank thinking the line should deleted (i.e. replaced with nothing), but the newline and endline characters remain.


Source: (StackOverflow)

How can I search and replace in multiple Word files?

I am looking for a way to do search and replace in many Word (.doc) files (for the purpose of automation of the process).

The software I found so far only allows me to search, but not replace.

How can I do that with Word?


Source: (StackOverflow)

how to do a vim search inverse search for all lines with out text

with grep I can do a grep -v "my search" to get all the lines with out "my search"

with sed I can sed '/baz/!s/foo/bar/g' to find replace text on lines with out baz

Is there a way to do the same thing vim. And is it possible but with out the "s///" syntax. Using just the "/" search syntax.


Source: (StackOverflow)

Replace text when in visual-block mode

Maybe I'm searching the wrong way, but I've failed to find out how to do this.

Here's the scenario: I have a list in a text file where I want to insert the same word on multiple lines, here's an example text:

12.1           Item1
12.2           Item2
12.3           Item3

Now I visual-block mark the 8th column, indicated with underscores below, and intend to replace part of the whitespace with Done without moving the item column:

12.1   _       Item1
12.2   _       Item2
12.3   _       Item3

I expected that I could go into replace mode, but I can only enter insert (I), append (A), or change-mode (c). The change-mode comes close to what I want: if I know the length of the word the block can be set to the same width.

Is there something I'm missing here?


Source: (StackOverflow)

Replacing all special/accented characters with equivalent regular characters in Notepad++

I'm trying to figure out a way to automatically search and replace all special/accented letters/characters (such as Â/Ô) with the equivalent regular letters/characters (A/O) in Notepad++.

Tried using ToolFx but it didn't work.


Source: (StackOverflow)