How can I re-Order fields in pipe delimited file?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

How can I re-Order fields in pipe delimited file?

Post by steve1040 »

I have a pipe delimited file with data that looks like this

ERFSYS1064|0718900798|1|S|2010-01-21 07:31:00
ERFSYS1032|0719600582|1|S|2010-02-17 11:00:00
ERFSYS1025|0719600582|1|S|2010-02-17 11:00:00
ERFSYS1025|0720801347|1|L|2010-01-18 16:30:00
ERFSYS1032|0722501524|1|S|2010-01-25 14:13:00
ERFSYS1025|0723000269|1|S|2010-01-17 11:00:00


I need to re-order the fields to look like this

0718900798|S|ERFSYS1064|1|2010-01-21 07:31:00
0719600582|S|ERFSYS1032|1|2010-02-17 11:00:00
0719600582|S|ERFSYS1025|1|2010-02-17 11:00:00
0720801347|L|ERFSYS1025|1|2010-01-18 16:30:00
0722501524|S|ERFSYS1032|1|2010-01-25 14:13:00
0723000269|S|ERFSYS1025|1|2010-01-17 11:00:00


Thanks
Steve
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: ([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)
Replace with: \2|\4|\1|\3|\5

[X] Regular expression

Replace All
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

Post by steve1040 »

ben_josephs wrote:Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: ([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)
Replace with: \2|\4|\1|\3|\5

[X] Regular expression

Replace All
Ben,
I tried this and I get a "Cannot find regular expression" popup

UPDATE: I found the problem - I had a newline /n at the end.

Thanks again
Steve
Post Reply