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!

CR XI - Need help with formula to parse string

Status
Not open for further replies.

ReportDr00

IS-IT--Management
Mar 2, 2007
194
US
Hello

I have a string field that contains data like below

med1 100mg
med2 10mg
med3 50mg

i am interested in creating the formula called strength and extract 100mg, 10mg, 50mg etc from above data.

mg is key here and get 3 to 4 characters on left of mg that will give me a number.

regards

armani
 
If the data is always in the format you indicated use this formula

//strength
SPLIT({table.field}," ")[2]



_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 

no it could have more words before and after numerica value like alfenta 100mg/ml ampul or alfentanil 500mg/ml amp

thanks
 
If there is only one "mg" per row, try this:

stringvar array x := split({table.string}," ");
numbervar i;
numbervar j := ubound(x);
stringvar y := "";
for i := 1 to j do(
if "mg" in x then
y := x
);
y

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top