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

How to split 2nd delimiter in string? CR 9.0

Status
Not open for further replies.

Digitalcandy

IS-IT--Management
May 15, 2003
230
0
0
US
I have some data such as the following:

L41-0080H1/H1-18X24
L43-0050H1/H0-9X12

I'd like to be able to split it at the second hyphen so that it reads...

L41-0080H1/H1
L43-0050H1/H0



I have the following formula, but it splits at the first hyphen, not the second.


Stringvar array MatCode := Split({MaterialCode.MatCode},"-");
MatCode[1];


So with the above code, my sample data ends up looking like...

L41
L43
 
Hi

Is the data always formatted like "L41-0080H1/H1...." ??
If so, you could create a formula and use
LEFT(fieldname,13)...

good luck

 
Try:

stringvar array x := split({table.string},"/");
stringvar array y := split(x[2],"-");
x[1]+"/"+y[1]

This assumes that there is always a "/" and that there is always a hyphen in the element after the "/".

-LB
 
Thanks Ibass, but it only works for some of my data. On others I get a substring error.

On 98% of my data, it ends with a size. The trailing 18X24 in the data L41-0080H1/H1-18X24 is a size, so if I could somehow delete the last 5 or 6 characters of every field, that should give me what i need. I can do an IF statement based on another field to determine whether i need to clip off 5 or 6 characters.

Preceding the size, the number of characters can vary wildly, so the evaluation would have to come from the right not the left.

Thanks
 
Ha! I found a simple solution.



IF {MaterialCode.Width} < 10
THEN

(stringvar matcodereversed := Mid(strReverse({MaterialCode.MatCode}),6);
strReverse(matcodereversed))

ELSE
(stringvar matcodereversed := Mid(strReverse({MaterialCode.MatCode}),7);
strReverse(matcodereversed))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top