Former Member

### Extract a specific data from a string in Crystal Reports

Suppose the data is in this format

----------------------------

Variable 7.5% codes

Temporary 10.5% codes

codes 58.5%

10%

20%

----------------------------

How to extract numeric part from the string like

7.5

10.5

58.5

10

20

10|10000 characters needed characters exceeded

Dec 12, 2017 at 07:30 PM

Hi Tanmay,

I guess you didn't see my solution in your comment:

Hi Tanmay,

Change your formula to check if the result is a number like:

```stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");

If NumericText (myResultArray[UBound(myResultArray)]) Then
myResultArray[UBound(myResultArray)]
Else "-";```

This will display a "-" if there are no numbers to extract.

Brian

10|10000 characters needed characters exceeded
• Dec 06, 2017 at 07:00 PM

Hi Tanmay,

Change your formula to check if the result is a number like:

```stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");

If NumericText (myResultArray[UBound(myResultArray)]) Then
myResultArray[UBound(myResultArray)]
Else "-";```

This will display a "-" if there are no numbers to extract.

Brian

10|10000 characters needed characters exceeded
• Dec 06, 2017 at 03:03 AM

stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");
myResultArray[UBound(myResultArray)];

10|10000 characters needed characters exceeded
• Former Member
Dec 12, 2017 at 11:15 AM

Hi Millet,

Thanks it worked but somehow

my data also include only the string like

------------------------

Not Eligible - temp

Eligible - Temp

Variable %

Private based

--------------------------

Note like the line Variable % contains no numbers so the output for this rows should be '-'

right now it's outputting the

-------------

Temp
temp

based

--------------

10|10000 characters needed characters exceeded
• Former Member
Dec 06, 2017 at 04:29 PM

Hi Millet,

Thanks it worked but somehow

my data also include only the string like

------------------------

Not Eligible - temp

Eligible - Temp

Variable %

Private based

--------------------------

Note like the line Variable % contains no numbers so the output for this rows should be '-'

right now it's outputting the

-------------

Temp
temp

based

--------------