tags:

views:

6012

answers:

5

I have quite a large list of words in a txt file and I'm trying to do a regex find and replace in Notepad++. I need to add a string before each line and after each line.. So that:

wordone
wordtwo
wordthree

become

able:"wordone"
able:"wordtwo"
able:"wordthree"

How can I do this?

+5  A: 

Assuming alphanumeric words, you can use:

Search  = ^([A-Za-z0-9]+)$
Replace = able:"\1"

Or, if you just want to highlight the lines and use "Replace All" & "In Selection" (with the same replace):

Search = ^(.+)$

^ points to the start of the line.
$ points to the end of the line.

\1 will be the source match within the parentheses.

Jonathan Lonowski
+2  A: 

Use a Macro.

Macro>Start Recording

Use the keyboard to make your changes in a repeatable manner e.g.

home>type "able">end>down arrow>home

Then go back to the menu and click stop recording then run a macro multiple times.

That should do it and no regex based complications!

Rob Stevenson-Leggett
What is "complications" supposed to mean? :-)
Tomalak
+1 for ease of use! I needed to append a 'tab' to the end of each line in a file and this tip did the trick.
NateJ
A: 

Out of curiosity, how would I replace all the (in a 1line html file) with (and a newline)?

I tried putting in Notepad++ Find and Replace using regexp Find: <\/\w+> Replace: \1\n

but it didn't give me the original and only replaced each closing tag with a newline so only half the job done.

A: 

I used to get files containing ">" , "<" , """ and in turn I need to replace them by > , < , " with help of Regular Expression. Please guide How I could set up the Macro for that in Notepadd++.

A: 

[thanks this is super helpful stuff]

Air Conditioners