Page 1 of 1

How do I find and replace a newline character (\n) in a...

Posted: Mon Jul 18, 2005 4:31 pm
by Webbhe
specific column position?

I want to insert 28 spaces before the newline character when the newline character appears in column 171 in order to make the record length equal 200:

2004011220040112 00000133.96 0000001.000 00000000.00 00000133.96078244\n

OR, is there a way to make all records the same length?

TIA...webbhe

Posted: Mon Jul 18, 2005 6:36 pm
by ben_josephs
Here's one way:
Find what: ^.{170}$
Replace with: \0____________________________

[X] Regular expression
where _ represents a space (there are 28 of them).

(If the newline character is in column 171, the record length is 170. So adding 28 spaces makes the record length 198, not 200.)

This assumes you are using POSIX regular expression syntax:
Configuration | Preferences | Editor

[X] Use POSIX regular expression syntax