Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Exracting Number from string

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
halifaxman
Asked:
halifaxman
  • 2
1 Solution
 
mlmccCommented:
You want to capture everything from the first digit found until a non-digit, / , -, and SPACE is found?

Any other variations?

mlmcc
0
 
peter57rCommented:
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
 
mlmccCommented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now