A Puzzle For The Pros

General questions about using TextPad

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

Post Reply
Trey

A Puzzle For The Pros

Post by Trey »

Hello,

Let me start by saying that I have learned so much from some of you people that post here from checking the search engine and I respect and admire you and this great product.

I am trying to create a macro that will get rid of text in a certain string. I have read and reread the help file wich is extremely enlightening, however I tend to learn better from disecting someone elses work.


HERE IS THE STRING
#234253434 1112 mason dr. 245,346,845,1342

This is the configuration I need when the macro finishes.

#234253434:245
#234253434:346
#234253434:845
#234253434:1342


I am almost positive that this can be achieved with Textpad and felt I was close a few times, but never quite got it figured out.


Thanks,


Trey
Jeff Epstein

Re: A Puzzle For The Pros

Post by Jeff Epstein »

Depending on how specific you need to be, here is a possible solution:

--------------------------
---- REPLACE ----
--------------------------
Find what: ^\([^ ]+\) [0-9]+ [^0123456789]+\([0-9]+\),\([0-9]+\),\([0-9]+\),\([0-9]+\)$
Replace with: \1:\2\n\1:\3\n\1:\4\n\1:\5
Regular Expression: [X]
-------------------

This assumes that:
--the first space denotes the end of the part that should precede the colons.
--digits, and then some non-digits (1) follow that first space, and (2) precede the first number that should be found after the colons.
--there are exactly four numbers divided by a single comma.

This at least gives you something to start with.

:' )
Jeffy
http://www.jeffyjeffy.com/textpad
Roy Beatty

Re: A Puzzle For The Pros

Post by Roy Beatty »

Address data is inherently messy, often because each address was manually entered by a different human being. It would be nice to have the messy data fields at the *end* of your record -- but I realize you inherited this data.

Jeff gives a good solution, but for myself, I'd like more varied examples of the input lines. The examples should answer these questions:<br>
o Is the street address fixed length, padded if need be? <br>
o Do street addresses *always* start with a number? <br>
o Is the number "pure" or not? Eg, 222b Baker Street.<br>
o Is the street address blank or missing in any cases? <br>
o Can we count on "." to end all street addresses? <br>
o Do all lines start with #12digits and end with nnn,nnn,nnn,nnnn?

I tried this first pass find expression: ^\([^ ]+\) .+\([0-9,]+)$<br>
to test how "greedy" the .+ would be -- it grabs from the start of address to the next to the last character -- too greedy.

Roy

PS: Greetings, Jeff!
Post Reply