These have always given me trouble too; I don't even try to get it
right on my first attempt. It's always either padding the first
Position to start the returned text after, not on, the first
delimiter; or trimming the length because I want "up to", not
"including", the last delimiter that trips me up.
I just see what I get and then change a pad/trim on one side or the
other to get what I want.
And often these are not so easy as "from the first occurrence of x to
the first occurrence of y". Parsing space-aligned columns of phone
switch reports and logs comes to mind.
Slowly over the years though, brute force repetition has conditioned
me to dread these less than I used to.
geoff
On Nov 17, 2009, at 4:54 PM, Richard S. Russell wrote:
Geoff Graham's solution came thru just as I was composing the
following, but what the heck, I'll send it along anyway because it
shows one technique for breaking things down into bite-size pieces
leading up to the solution:
Formats:
Middle ( text ; start ; numberOfCharacters )
Position ( text ; searchString ; start ; occurrence )
Pseudocode:
Middle ( given; P1; P2 - P1 ), where ...
• P1 is the starting position (the character right after the ")"
and
• P2 is the ending position (the character right before the ";")
and
• both are computed using the "Position" function