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

Extract certain data from a string 1

Status
Not open for further replies.

cjkirkham

Programmer
Jan 9, 2005
2
0
0
CA
I have a field called cpic_info that contains data such as (Name: Sammy Cpic Address: 123 Main St Regina SK Date of Birth: 1978-12-20 Gender: Male Height: 5 feet 5 inches Weight: 123 pounds Place of Birth: Regina)

I need to be able to extract the following in this format:
Sammy Cpic
123 Main St
Regina, SK
1978-12-20
Male
5 feet 5 inches
123 pounds
Regina

Each field is seperated by a ":", but I can not seem to split the string apart. Any suggestions???

Thanks.
cjk
 
This is a little long, and not as fleixbile, but it is what you need in this case. There is not standard pattern to just split on:

replace(replace(replace(replace(replace(replace(replace({table.field},"Name: ",""),"Address: ",chr(13)),"Date of Birth: ",chr(13)),"Gender: ",chr(13)),"Height: ",chr(13)),"Weight: ",chr(13)),"Place of Birth: ",chr(13));


~Brian
 
HI cjkirkham,
Try this one also.


//var is ur data field
stringVar array arrvar; //declare array
stringvar result;
numbervar i;

abc:=Split(var,":"); //split data filed

//loop is for variable no of entries,
//for fixed u can hard code array index
//i.e. abc[2]+chr(13)+abc[4]+chr(13).....

for i :=2 to ubound(abc) step 2 do
result:=result+abc+chr(13);
result;


cheers
Lalit Rana
 
Lalit,

I think I can use this for my problem, but I am not sure what you are doing?

for i :=2 to ubound(abc) step 2 do
result:=result+abc+chr(13);
result;

What are you starting at i=2? why are you moving through the data by 2?

and would I use this as the formula in a report?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top