Link to home
Start Free TrialLog in
Avatar of DTRON04
DTRON04

asked on

Formula to Split a String @ alpha/numeric values

Hey experts,

I need a complete crystal formula that can take this string
AAA111
and Split it when the AAA changes to 111 then select either the AAA(0) or 111(1)  to return back to the report.

Big points hope someone can get me a quick answer.
Thanks in advance!



Avatar of frodoman
frodoman
Flag of United States of America image

This formula gives you the 111 portion:     mid('AAA111',instr('AAA111','1'));

This formula gives you the AAA portion:    mid('AAA111',1,len('AAA111')-instr('AAA111','1')+1);


Obviously this is a simple example though - are you asking to split based on any number or will it always be a '1'?

frodoman
SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ebolek
ebolek

can you give more info
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DTRON04

ASKER

Hey all thanks for all that i think bdreed35 is the closest to what i need

Let me explain some more logic.

Basically the example i gave was for alpha/numeric sepration the characters and lengths can be different.
The constants are this:

the set of letters will always be in the beginning and should never go over holding 5 places, usually 3 to 4.
Then when i hit the numeral that is what i want to split on basically returning the opposite values in 2 seperate formulas.

that is exactly what your doing right  bdreed?

i will try it within the hour i am currently working on something else.
didn't have time get this one on my own, thanks again guys!!
Both the formula I provided and the one Brian (bdreed) provided will give you what you want - two different ways to do basically the same thing.

frodoman
Yes, that is exactly what I am doing.

You can create a second formula and reference the other variable so that you can display both values:

@Display_Text

EvaluateAfter({@OtherFormulaName});
stringvar strText;
Avatar of DTRON04

ASKER

alright guys, thanks!!
Brian your solution worked right out of the box for me.

frodo i will five you 200 for being first.
i understood Brian's style a bit better then yours so that may have been why i kept getting a 0 value or integer error on your solution.

My skills in crystal cyntax are lacking greatly, is there a good book or reference guide i can get to understand the crystal syntax better?
i develope in VB/SQL for web and windows apps and love crystals rapid developement features but the syntax kicks my a** everytime i have to get somewhat complicated with it.
what language is it based on anyway?

regardless, thanks again!
 
Book name : Brian Bischof Crystal Reports .NEt programming . Great book I recommend to everyone
Crystal Syntax: C
Regards
Emre
The syntax is a hybrid of vb & c.  The keywords are vb-like but the bracketing is c-like.  It is odd, however you can opt to use Basic syntax instead of Crystal.  The Basic syntax is virtually identical to vb.

frodoman
If you are used to VB, you can use Basic syntax to write the formulas.  There is no difference in the amount of speed of either one so it is really based upon your preference.

I recommend leaving the report you have already alone, but you can experiment.  When your in the formula editor, just change the drop down bos in the toolbar from Crystam Syntax to Basic Syntax.
Avatar of DTRON04

ASKER

thanks i will try to play in just basic and see how i fair, are you guys sitting beside each other or something?
it seems like you were racing to see who could enter key first on those last responses.