Change order of fields in text file with 1000 lines

General discussions about Advanced Find and Replace
Post Reply
zootycoonvn
Posts: 13
Joined: Mon Aug 20, 2007 9:25 am

Change order of fields in text file with 1000 lines

Post by zootycoonvn » Tue Aug 21, 2007 6:39 am

I have 1 file txt have 1000 lines.
1/Such as :
id---name---dob---address---email
12---John---11101978---456 Texas---abs@aol.com
13---John---12121978---423 Texas---xax@aol.com
Result :
dob---id---name---dob---address---email
11101978---12---John---11101978---456 Texas---abs@aol.com
12121978---13---John---12121978---423 Texas---xax@aol.com

2/ Such as :
id---name---day---month---year---address---email
12---John---11---10---1978---456 Texas---abs@aol.com
13---John---12---12---1978---423 Texas---xax@aol.com

Result :
day---month---year---id---name---day---month---year---address---email
11---10---1978---12---John---11---10---1978---456 Texas---abs@aol.com
12---12---1978---13---John---12---12---1978---423 Texas---xax@aol.com

3/Such as :
ID---email---address---phone---name
12---asf@awe.com---456 Texas---1234567890---John
13---awer@yahoo.com---123 Cali---9852367921---Mary

Result:
ID---name---email---phone---address
12---John---asf@awe.com---1234567890---456 Texas
13---Mary---awer@yahoo.com---9852367921---123 Cali
Plzz help me.Thanks.

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Re: Change order of fields in text file with 1000 lines

Post by Abacre » Tue Aug 21, 2007 8:02 pm

Go to main menu - Action - Options - Batch Replace
check "Modifier M"
uncheck "Modifier S"
uncheck "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".

For the first case use the following:

Search for:
^(\d+---.*---)(\d+---)
Replace with:
$2$1$2

For the second case use the following:

Search for:
^(\d+---.*---)(\d+---\d+---\d+---)
Replace with:
$2$1$2

For the third case use the following:

Search for:
^(\d+)---(.*)---(.*)---(.*)---(.*)$
Replace with:
$1---$5---$2---$4---$3

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

zootycoonvn
Posts: 13
Joined: Mon Aug 20, 2007 9:25 am

Re: Change order of fields in text file with 1000 lines

Post by zootycoonvn » Wed Aug 22, 2007 7:39 am

Many thanks to Roman & site.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests