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

General questions about using TextPad

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

Post Reply
Webbhe
Posts: 6
Joined: Tue Oct 21, 2003 6:01 pm

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

Post 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
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
Post Reply