Searching between columns

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

Searching between columns

Post by gcotterl »

How can I find a string (such as ' 28') only between columns 31 and 375?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

^.{30,373}28
Adjust as appropriate.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

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

Post 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]
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post 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.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

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

Post by ben_josephs »

Which version of TextPad are you using?
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

Version 5.3.1
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Why? That is two major versions ago.

Use \ instead of $ in the replacement expression.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

That works!

Thanks,
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
gcotterl
Posts: 252
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

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

Post by ben_josephs »

Just the last one.
Post Reply