Page 1 of 1
Move text
Posted: Mon Oct 28, 2013 8:34 pm
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?
Posted: Mon Oct 28, 2013 11:43 pm
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
Posted: Tue Oct 29, 2013 7:48 pm
by gcotterl
Everything in the row gets deleted, leaving only the regular expression in the "REPLACE WITH" box at the left margin.
Posted: Tue Oct 29, 2013 9:39 pm
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.)
Posted: Tue Oct 29, 2013 10:06 pm
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]
Posted: Tue Oct 29, 2013 11:11 pm
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 $.
Posted: Tue Oct 29, 2013 11:18 pm
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
Posted: Tue Oct 29, 2013 11:25 pm
by ben_josephs
That input doesn't match your description.
What happened when you used \ instead of $ in the replacement?
Posted: Tue Oct 29, 2013 11:44 pm
by gcotterl
Instead of $1
I tried \1
and it worked!
Posted: Tue Oct 29, 2013 11:46 pm
by ben_josephs
You're welcome.
Posted: Wed Oct 30, 2013 12:05 am
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).