Page 1 of 1

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

Posted: Tue Dec 21, 2010 2:38 pm
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

Posted: Tue Dec 21, 2010 5:04 pm
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

Posted: Wed Dec 22, 2010 1:40 pm
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