Moving text from the end of the line to beginning

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

Moving text from the end of the line to beginning

Postby Nikotine » Tue Jan 24, 2006 9:16 am

**SORY ADMIN I POSTED IN THE WRONG FORUM< SHOULD BE IN MACROS**

I have a CSV file of contacts I need to sort out.

Code: Select all
Firstname,Lastname,Email@Email.com
Firstname,Lastname,Email@Email.com
Firstname,Lastname,Email@Email.com
Firstname,Lastname,Email@Email.com


I need to move the email to the front of the line and leave the first and last names intact as such

Code: Select all
Email@Email.com,Firstname,Lastname
Email@Email.com,Firstname,Lastname
Email@Email.com,Firstname,Lastname
Email@Email.com,Firstname,Lastname


I have had no luck with doing the macro so far spent many hours trying different features, any help would be appreciated..

Thanks in advance for any responses.
User avatar
Nikotine
Newbie
 
Posts: 4
Joined: Tue Jan 24, 2006 12:00 am

Re: Moving text from the end of the line to beginning

Postby Nikotine » Tue Jan 24, 2006 9:42 am

InsertMode
ColumnModeOff
HexOff
UnixReOff
Loop
Find RegExp ","
Find RegExp ","
IfFound
StartSelect
Key END
Cut
Key HOME
Paste
","
Key HOME
Key DEL
Key END
Else
ExitLoop
EndIf
EndLoop
Top
UnixReOn

//Works but its not pretty

//Any Speed up pointers will be Much appreciated(No real need. This script did my address book in 30 seconds flat, but constructive critisim is always welcome)
User avatar
Nikotine
Newbie
 
Posts: 4
Joined: Tue Jan 24, 2006 12:00 am

Re: Moving text from the end of the line to beginning

Postby Mofi » Tue Jan 24, 2006 10:54 am

A simple regular expression replace in UltraEdit style will do the same:

Find What: %^(*,*^),^(*^)$
Replace With: ^2,^1
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4069
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Moving text from the end of the line to beginning

Postby Nikotine » Tue Jan 24, 2006 7:38 pm

wow

Maybe somehow by luck I posted in the right forum looking for the wrong solution. Anyway, where can I find some sort of tutorial on regular expressions? I would like to know why how that worked rather than it just does. And the help file does not go into any type of detail.

Thanks

I understand the % begining of the line, but the ^ does not make sense to me which caracter is that skipping over? (*,* this makse sense to me like in unix command line it seems to simpley use anything','anything then there is the ^ and the carat which I don't understand.

**EDIT**

nevermind I think I have it all sorted out ... thanks for the post and helping me figure on a new way of doing this.
User avatar
Nikotine
Newbie
 
Posts: 4
Joined: Tue Jan 24, 2006 12:00 am


Return to Find/Replace/Regular Expressions