Solved

Exracting Number from string

Posted on 2013-06-14
3
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 101

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 101

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

631 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