Jump to content

Pull text from the middle

This topic is 6599 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Text calculations and I don't get along. I have a string which always looks like this:

StaffID ProdID TypeID xxxx xxxxx YYYYMM

The x's represent what I need to isolate and can be one to several words. The IDs vary in length and type but are always separated by a space and always only one word. I've tried:

MiddleWords ( BottleKey; 4 ; LeftWords( BottleKey; WordCount(BottleKey) - 1 ))

... but that gives me xxxx xxxx YYYYMM

I've tried:

Right(BottleKey; Length(BottleKey) - Position(BottleKey; " "; 1; 3) )

... which gives the exact same result. Bummer. I can't drop the YYYYMM off the end no matter what I try!!

Can someone help me with the text calculation and (more importantly) HOW you approached this (from left, right or middle) so I can learn for the next text calculation I encounter. Thank you!!!

LaRetta smile.gif

Link to comment
Share on other sites

How about

MiddleWords( BottleKey; 4; WordCount(BottleKey) - 4 ) ?

Your first calc almost has it, but you only need to determine how many X words there are by subtracting 4 (for the StaffId, ProdId, TypeId, and YYYYMM).

Link to comment
Share on other sites

Oh yeah!!! Perfect, of course!

JT, it always seems so simple when you do it!! I just spent 4 hours on this stinking puppy!!!! I had reached a point of deciding to run two scripts ... one to end up with above result and again to split off the right YYYYMM. blush.gif

I wonder if anyone else ever has done something so silly to get the right text strip (as to run through the records twice)?? But I'm trying very hard not to write trash. Thank you for helping me keep my solution clean!!


Link to comment
Share on other sites

This topic is 6599 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.