Page 1 of 1
Searching between columns
Posted: Wed Jan 22, 2014 8:45 pm
by gcotterl
How can I find a string (such as ' 28') only between columns 31 and 375?
Posted: Wed Jan 22, 2014 10:24 pm
by ben_josephs
^.{30,373}28
Adjust as appropriate.
Posted: Wed Jan 22, 2014 11:47 pm
by gcotterl
Here's my data:
[size=7]390090002-1 2013 065-027 0100000 01000000000303985 28000700000032243 68137700000000790
009705225-8 2013 025-605 0100000 01000000000019019 28100600000009999
009704721-6 2013 025-605 0100000 01000000000018153 28100600000009999
009727115-0 2013 005-643 0100000 01000000000025920 28100600000010000
009722577-9 2013 065-740 0100000 01000000000020910 28100600000010000
379251025-6 2013 005-060 0100000 01000000000055000 28100600000010000 68136300000000120
389312011-4 2013 005-062 0100000 01000000000149940 68100600000014994 68136300000001002
379140078-1 2013 005-058 0100000 01000000000101326 68136300000000062 68235700000001984
379140088-0 2013 005-058 0100000 01000000000073413 68136300000000081 68235700000003936
389372017-6 2013 005-062 0100000 01000000000203082 68136300000000094 68235700000007830[/size]
I adjusted ^.{30,373}28 to ^.{33,373}28
I pasted ^.{33,373}28 in the "Find What" box and typed ' 28' (i.e., 10 spaces and '28') in the "Replace With" box. When I click "Replace", all of the characters to the left of '28' get deleted.
Here's the result:
[size=7] 28000700000032243 68137700000000790
28100600000009999
28100600000009999
28100600000010000
28100600000010000
28100600000010000 68136300000000120
389312011-4 2013 005-062 0100000 01000000000149940 68100600000014994 68136300000001002
379140078-1 2013 005-058 0100000 01000000000101326 68136300000000062 68235700000001984
379140088-0 2013 005-058 0100000 01000000000073413 68136300000000081 68235700000003936
389372017-6 2013 005-062 0100000 01000000000203082 68136300000000094 68235700000007830[/size]
Posted: Thu Jan 23, 2014 9:15 am
by ben_josephs
It is helpful to explain the whole problem in the initial post.
Try this:
Find what: ^(.{33,373})28
Replace with: $1__________28 [Replace the underscores with spaces]
Posted: Thu Jan 23, 2014 1:56 pm
by gcotterl
I didn't know of the pfoblem until after I tried your first suggestion.
I will try your new suggestion when I get to my office.
Posted: Thu Jan 23, 2014 5:19 pm
by gcotterl
Hi Ben Josephs,
I'm still having the problem.
Here's one line of my data:
[color=red]966170017-1 2013 094-007 0104046 01000000000000010 03652000000000000 04530100000000000[/color] 28527500000000002 68540200000001160
Using your latest suggestion, here's the result of the "Replace":
$1__________28527500000028300 68540200000000746
(All of the characters in [color=red]red[/color] are being replaced by the expression in the "Replace With" box. (The underscores are spaces)
Posted: Thu Jan 23, 2014 5:32 pm
by ben_josephs
Which version of TextPad are you using?
Posted: Thu Jan 23, 2014 7:09 pm
by gcotterl
Version 5.3.1
Posted: Thu Jan 23, 2014 7:22 pm
by ben_josephs
Why? That is two major versions ago.
Use \ instead of $ in the replacement expression.
Posted: Thu Jan 23, 2014 7:58 pm
by gcotterl
That works!
Thanks,
Posted: Thu Jan 23, 2014 8:28 pm
by ben_josephs
TextPad 7 has a far more powerful regex engine than earlier TextPad versions. In this case a version 7 solution works with a trivial change in earlier versions. But in many cases a version 7 solution will have no near equivalent or no equivalent at all in earlier versions.
Posted: Thu Jan 23, 2014 9:15 pm
by gcotterl
If '28' occurs multiple times in each row, does your latest solution replace ALL occurrences in each row or just ONE occurrence in each row?
Posted: Thu Jan 23, 2014 10:11 pm
by ben_josephs
Just the last one.