Link to home
Start Free TrialLog in
Avatar of Metalteck
MetalteckFlag for United States of America

asked on

String Search in Crystal Report

I have comment field in my report that is delimited by commas and spaces;
ex:
Type=D, create user= test user1, modified user = test1, Apply to inventory
Captial#123456
SDE#78910

I'm trying to search the string and ONLY pull out the information that starts with SDE.

I"ve tried using the formula: split({L_HPCR.OBJECT},",")[4], but if the SDE# isn't right after the third comma, it won't display.

Anyone have any suggestions.

Thank you
Avatar of Mike McCracken
Mike McCracken

Try this

Local NumberVar SDE_Loc;
SDE_Loc := InStr({L_HPCR.OBJECT},"SDE");
Mid({L_HPCR.OBJECT},SDE_Loc)

mlmcc
Avatar of Metalteck

ASKER

At first it worked, but then I got an error saying" Start Position is less than 1 or not an integer".

Ideas?
Apparently you have strings without the SDE or NULL

Local NumberVar SDE_Loc;
If IsNull({L_HPCR.OBJECT}) then
   "No String"
Else
(
    SDE_Loc := InStr({L_HPCR.OBJECT},"SDE");
    If SDE_Loc > 0 then
        Mid({L_HPCR.OBJECT},SDE_Loc)
    Else
        "No SDE"
);

mlmcc

mlmcc
Thats perfect. One last question, what happens if SDE is in lowercase?
How would I capture all versions of the word sde?
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

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