Page 1 of 1

Substring/parse question

Posted: Thu Feb 07, 2013 12:15 pm
by Marley777
Hi, thanks for reading. Any help is greatly appreciated.

I need help with parsing data in an input field.

If I have the following in my varchar 255 input filed
part1-part2-part3-part4-part5

I want to put part1 and part2 in one field and all other parts in another field. The dash between part2 and part3 is not needed because it's a delimiter, but I need to keep the dash between all other parts because it's part of the data. Any ideas on how to do this?

Below is what I'm trying to do

Newfield 1
part1-part2

Newfield 2
part3-part4-part5

Posted: Thu Feb 07, 2013 1:56 pm
by chulett
Use Field() and tell it the field is "-" delimited. For the first part, take 2 fields starting from field 1, for the second take 3 fields starting with field 3. The optional argument after the field number to extract controls how many fields to extract. It defaults to 1 if you don't specify it.

Posted: Thu Feb 07, 2013 3:57 pm
by ray.wurlod

Code: Select all

NewField1 <--  Field(OldField, "-", 1, 2)
NewField2 <--  Field(OldField, "-", 3, 3)

Posted: Fri Feb 08, 2013 8:21 am
by Marley777
Thanks this worked for us.