Move text

General questions about using TextPad

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

Post Reply
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Move text

Post by gcotterl »

If position 48 contains a space followed by 6 more spaces, how can I MOVE the text after the space in position 48 one hundred positions to the right?


Alternatively: If position 48 contains a space followed by 6 more spaces, how can I DELETE the text after the space in position 48?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To move the text:
Find what: ^(.{47} )( {6}.*)
Replace with: $1[100 spaces]$2

[X] Regular expression

Replace All
To delete the text:
Find what: ^(.{47} ) {6}.*
Replace with: $1

[X] Regular expression

Replace All
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

Everything in the row gets deleted, leaving only the regular expression in the "REPLACE WITH" box at the left margin.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That is not entirely clear. Please post small examples of input and the corresponding faulty output. Enclose them in [code⁠]...[/code] blocks.

(A replacement expression is not a regular expression.)
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

[u][b]INPUT:[/b][/u]

[code]0ASMNT-NBR 000000081-3 1991
0000000 6,020.92 602.09 .00 6,623.01
0PAID STATUS PARTIAL PAID
0ASMNT-NBR 000000081-3 1992
0000000 6,531.45 653.14 .00 7,184.59
0PAID STATUS NOT PAID
0ASMNT-NBR 000000108-5 2006
0000000 317.25 31.72 .00 348.97
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1992
0000000 69.07 6.90 .00 75.97
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1993
0000000 75.72 7.57 .00 83.29
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1994
0000000 75.28 7.52 .00 82.80
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1995
0000000 75.65 7.56 .00 83.21
0PAID STATUS NOT PAID[/code]

========================================


[u][b]CORRESPONDING FAULTY OUTPUT:[/b][/u]

[code]0ASMNT-NBR 000000081-3 1991
$1
0PAID STATUS PARTIAL PAID
0ASMNT-NBR 000000081-3 1992
$1
0PAID STATUS NOT PAID
0ASMNT-NBR 000000108-5 2006
$1
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1992
$1
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1993
$1
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1994
$1
0PAID STATUS NOT PAID
0ASMNT-NBR 000000138-2 1995
$1
0PAID STATUS NOT PAID[/code]
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

... and don't Disable BBCode in this post.

Are you still using an old version of TextPad? If you want help with regexes please upgrade to version 7. In the meantime, in the replacement try using \ instead of $.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

I'm sorry about the "Disable BBCode"

I'm running TP 5.3.1

====

INPUT

Code: Select all

0ASMNT-NBR 000000081-3 1991 
0000000 6,020.92 602.09 .00 6,623.01 
0PAID STATUS PARTIAL PAID 
0ASMNT-NBR 000000081-3 1992 
0000000 6,531.45 653.14 .00 7,184.59 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000108-5 2006 
0000000 317.25 31.72 .00 348.97 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1992 
0000000 69.07 6.90 .00 75.97 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1993 
0000000 75.72 7.57 .00 83.29 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1994 
0000000 75.28 7.52 .00 82.80 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1995 
0000000 75.65 7.56 .00 83.21 
0PAID STATUS NOT PAID


========================================


CORRESPONDING FAULTY OUTPUT:

Code: Select all

0ASMNT-NBR 000000081-3 1991 
$1 
0PAID STATUS PARTIAL PAID 
0ASMNT-NBR 000000081-3 1992 
$1 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000108-5 2006 
$1 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1992 
$1 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1993 
$1 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1994 
$1 
0PAID STATUS NOT PAID 
0ASMNT-NBR 000000138-2 1995 
$1 
0PAID STATUS NOT PAID
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That input doesn't match your description.

What happened when you used \ instead of $ in the replacement?
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

Instead of $1
I tried \1
and it worked!
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You're welcome.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

My description referred to the original results which was caused by all rows having 6 spaces starting in position 48.

Eliminating the spaces after the last "significant" character of the text and the end of each row resulted in the example of the "faulty output" I sent you. (Apparently, in Configuation/Preferences/Document Classes/Default, ticking "Strip trailing spaces from lines when saving" doesn't work).
Post Reply