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

Help with string formula. 1

Status
Not open for further replies.

goduke

IS-IT--Management
Feb 13, 2006
65
US
I have a string field that looks like the following values:

Otbf.Srvr.Emalf.-
Otbf.Srvr.Swcb.-
Otbf.Srvr.Swcb.Abus1ss
Otbf.Srvr.Swcb.C
Acq.Tel.Tel.-

What I need is from the third period, over, taken off. So the above examples would be:

Otbf.Srvr.Emalf
Otbf.Srvr.Swcb
Otbf.Srvr.Swcb
Otbf.Srvr.Swcb
Acq.Tel.Tel

In the data, there is always a third period, and if there isnt anything after the period, then there is a dash, otherwise there is another word. No more than four words though. Any help would be great.

 
You could use SPLIT to separate and restore. Also UBOUND to check how many elements, so you don't try processing a data item that does not exist.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Could you give me an example of the syntax?
 
Try this:

stringvar x := {table.string};
stringvar array y := split(x,".");
stringvar z := "";
numbervar i;
for i := 1 to 3 do(
z := z + y + "."
);
left(z,len(z)-1)

-LB
 
That works PERFECTLY!

Can you give me a quick breakdown of how it works?
 
The split breaks it into three components with no periods. Then the loop adds the components back together again followed by a period. Then the last line trims off the ending period.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top