Print Page | Close Window

How to extract a string?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4362
Printed Date: 28 Apr 2024 at 8:18am


Topic: How to extract a string?
Posted By: gilfong
Subject: How to extract a string?
Date Posted: 24 Sep 2008 at 10:48am

Example of the data:

Progesterone Receptor (SP2)
Keratin 19 Rabbit PAb
CD22
 
How do I extract the 1st and 2nd word?



Replies:
Posted By: hilfy
Date Posted: 24 Sep 2008 at 12:50pm

There may be a more "elegant" way to do this, but try something like this:

NumberVar x;
x := InStr({table.field}, " ");  //get the position of the first space
x := InStr(x, {table.field}, " ");  //get the position of the second space
Left({table.field}, x-1)
 
Note that there is no semi-colon after the last statement.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window