Solved

Exracting Number from string

Posted on 2013-06-14
3
282 Views
Last Modified: 2013-06-26
I am using CR 2008

I have a text field in my report at present, it is manly in the format as below

Joe Bloggs - 01326839 -00000001 - Letter
John Smith - 2526261/2 - Memo
John Smith - 2526261 - 1 - Memo

There are variations like
1011121/2 - Letter

In each case I would like to extract the numbers in the text field, using the examples above the result would be

01326839 - 00000001
2526261/2
2526261 - 1
1011121/2

Is this possible?
0
Comment
Question by:halifaxman
  • 2
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 39247944
You want to capture everything from the first digit found until a non-digit, / , -, and SPACE is found?

Any other variations?

mlmcc
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 39247953
Have a go with this...


numbervar x:=0;
numbervar y:=0;
numbervar z:=0;
stringvar s1:="";

stringvar OK1:="1234567890/-";

stringvar inval:= {table.fieldname};        //YOUR fieldname here
z:=len(inval);
for x:=1 to z do
if inval[x] in OK1 then s1:=s1 & Inval[x];

//step 2
while s1[1]  in ["-","/"] do
s1:=mid(s1,2);

//step3
while right(s1,1) in ["-","/"] do
s1:=left(s1,len(s1)-1);

s1
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39247994
I think that is close but it doesn't include the blanks and it will return embedded numeric like

John1 Smith - 4321/345 - Memo

The blank is easy, just add it to the OK1 string
    stringvar OK1:="1234567890 /-";

Also need to include the blank when stripping leading and trailing characters

mlmcc
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now