Solved

Exracting Number from string

Posted on 2013-06-14
3
283 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

16 Experts available now in Live!

Get 1:1 Help Now