Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Pulling data out of a string

Pulling data out of a string

Pulling data out of a string

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 (


RE: Pulling data out of a string

Just a quick untested thought:


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";


RE: Pulling data out of a string

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close