Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling data out of a string

Status
Not open for further replies.

JasonKaufman

Programmer
Apr 13, 2006
46
0
0
US
I have a field, {tblProduct.Description_1} where "Pk" or "pk" or "PK" may or may not exist somewhere withing the string.
If it does exist, I want to pull out that 2 character string along with the the 2 characters to the left of the 'pk' string as this data would be a number (such as 1,2,10, 11, etc)

So if I have a field where the data is:
Wm Athletic Works Boys 3Pk Athletic Crew
the formula would return 3Pk

Zebra 10Pk- Multi Combo
would return 10Pk

If "Pk" does not exist, then return "1Pk"

I am using CRXI (11.5.12.1838)

Thanks!!
 
Just a quick untested thought:

{@PackSize}
whileprintingrecords;

stringvar origval := lowercase({tblProduct.Description_1});

numbervar lookupnum := instr(origval,"pk");

stringvar gotit;
IF lookupnum > 3 then gotit := right(left(origval,lookupnum+1),4) else gotit := "1pk";

gotit

 
Thanks fisheromacse,
your formula works as intended and I was able to modify it some for other non-pk instances.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top