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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting a field based on a delimiter

Status
Not open for further replies.

ErnstNoto

Programmer
Dec 20, 2009
48
SE
I have a description field in my database which I would like to split into two separate Fields in my report.

The information is always separated with a colon. I cant use the left/right function because the positions change.
The field contains information on a merchant on the rigt side, and the purchased product on the left. Cant finf any function based on a delimiter.

For example:

Merchant123456:product description
Merchant1234: Procuct description
Merchanr123456789: Product description

Would like to create two Fields where I would Call one "Merchant" and the other "Product"

Anyone with ideas on how to do that?

Thank you
Ernst

Best Regards
Ernst Noto
 
Hi Ernst,

If you're using FP/VFP the functions SUBSTR() and AT() would do it.

e.g.

"Merchant" = ALLTRIM(SUBSTR(OldField, 1, AT(":", OldField)))
"Product" = ALLTRIM(SUBSTR(OldField, AT(":", OldField) + 1))

hth

MarK
 
You can use the split function.

@merchant
[tt]whileprintingrecords;
stringvar merchant:= split({Yourfield},':')[1];[/tt]


@product
[tt]whileprintingrecords;
stringvar product:= split({Yourfield},':')[2];[/tt]
 
Thanks!:)

That was not to hard :)

Best Regards
Ernst

Best Regards
Ernst Noto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top