Add a letter to the first of each line.

Find, replace, find in files, replace in files, regular expressions

Add a letter to the first of each line.

Postby dkchandler » Thu Mar 31, 2005 10:54 am

How can I add a letter to the first of each line???

Example:
Change this:
0016232 This is line 1.
0013488 This is line 2.

to this:
e0016232 This is line 1.
e0013488 This is line 2.

Thanks
User avatar
dkchandler
Newbie
 
Posts: 5
Joined: Tue Aug 03, 2004 11:00 pm
Location: Little Rock, AR

Re: Add a letter to the first of each line.

Postby dkchandler » Thu Mar 31, 2005 2:32 pm

I wrote a macro to add an 'e' in the first pos of the line, then I had the macro run 18,000 times to get all lines. It took some time, but it worked. :D
User avatar
dkchandler
Newbie
 
Posts: 5
Joined: Tue Aug 03, 2004 11:00 pm
Location: Little Rock, AR

Re: Add a letter to the first of each line.

Postby markwi » Thu Mar 31, 2005 5:06 pm

Try this:

Invoke the Search/Replace dialog and enter following Unix regular expression strings:

Find: ^(.*)$
Replace With: e\1

Basically that says, find each line and store it as avariable.

Then replace with a constant e followed by each variable found.

And there you are.

Now, if you didn't want the whole file done, just select the text you want this done for and check the box for selected text only.

Enjoy.
User avatar
markwi
Newbie
 
Posts: 1
Joined: Thu Mar 31, 2005 12:00 am

Re: Add a letter to the first of each line.

Postby wodder » Fri Apr 01, 2005 7:21 pm

Here's another way:

(Macro Form)

Top
ColumnModeOn
ColumnInsert "e"

(Using the keyboard)

ALT-C (to turn on column mode)
ALT-L,I (column menu, insert)
CTRL+HOME (go to top of file)
e (the letter you want to insert)
User avatar
wodder
Newbie
 
Posts: 2
Joined: Mon Sep 13, 2004 11:00 pm

Re: Add a letter to the first of each line.

Postby dkchandler » Wed Apr 06, 2005 3:48 pm

wodder

That works great! and much faster then my macro.

Thanks guys,

Danny
User avatar
dkchandler
Newbie
 
Posts: 5
Joined: Tue Aug 03, 2004 11:00 pm
Location: Little Rock, AR


Return to Find/Replace/Regular Expressions