Former Member

# How to trim 1122 out from 1006;INV1122;SRNO1236

Post Author: leongcy23

CA Forum: Formula

Dear forums buddy,

I got a situation here where I need to extract out the 1122 from the Ref note 1006;INV1122;SRNO1236. Now it will be easy if the length for the first few integer is fix. Mid (Cal.Ref, 9, 4)

But now my problem is that the 1006 sometimes will be in 2 or 3 character only. So its hard for me to extract it.

So do anyone have any idea on this? Need help here. Thanks

Anson

10|10000 characters needed characters exceeded

### Related questions

• Former Member
Posted on Jun 11, 2007 at 07:21 PM

Post Author: Charliy

CA Forum: Formula

Is there anything else that is constant? Are ther always three letters after the first semicolon? Do the target numbers alway precede the second semicolon?

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 11, 2007 at 07:48 PM

Post Author: SKodidine

CA Forum: Formula

I am not sure when you mention "extract out" if you wanted the string minus 1122 or just want the 1122.

If you want the string minus 1122 here is what you do.

stringvar x := '1006;INV1122;SRNO1236';stringvar y := '1122';

mid(x,1,(instr(x,y)-1)) & mid(x,(instr(x,y)+4),len(x));

If you want the 1122 alone then do this:

mid(x,(instr(x,y)),4);

replace x with the table field.

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 12, 2007 at 02:20 AM

Post Author: leongcy23

CA Forum: Formula

Dear Charliy,

There is no others constant value other than the first 4 digit. The integer before first semicolon is amount (\$), so its will change always. Whereby integer after first semicolon and second semicolon is code, so the length is fix.

Yes, there's always 3 letther after the first semicolon.

Yes, the target no. always precede the second semicolon

Thanks

Anson

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 13, 2007 at 02:34 AM

Post Author: leongcy23

CA Forum: Formula

Now what I want to know is how to take out the value after the first semicolon and before the second semicolon. There is always two semicolon in this Ref notes.

Thanks

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 13, 2007 at 04:37 PM

Post Author: SKodidine

CA Forum: Formula

split(x,";")&#91;2&#93;;

where x is Ref Notes.

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 13, 2007 at 07:31 PM

Post Author: Charliy

CA Forum: Formula

mid(split({cal.ref),':',&#91;2&#93;),4,4)

You might have to tune it a little, but the Split gives you what comes after the first semicolon, then the Mid gives you 4 characters starting at the 4th character.