Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Extraction Formula Help

Posted on 2006-03-21
5
Medium Priority
?
538 Views
Last Modified: 2008-03-10
Experts:

Can you tell me the formula to use in order to extract the characters found in the SECOND TO THE LAST number in this type of string?

N_1051010_98_822
N_1050815_2_14


In this above example I need to extract the "98" and the "2" in the above 2 examples. It would always be the number (1-3 digits) immediately BEFORE the last "_"

What I will more than likely needing to do is LINK one table that contains this NUMBER to another table that has the number is a more normal format of 98.

ie.

TABLE 1

DATE          CODING
01/01/05     N_1051010_98_822
01/05/05     N_1050815_2_14

TABLE 2

DATE          BATCH
01/01/05      98
01/05/05       2

I'm needing to LINK TABLE 1 (CODING "Extract" number ie. 98) with TABLE 2  BATCH number field.

How can I first of all extract the number, then if possible use the extract to LINK the two tables???

Thanks
Mike

0
Comment
Question by:MIKE
4 Comments
 
LVL 6

Assisted Solution

by:PWinter
PWinter earned 1000 total points
ID: 16252822
Hi.

InStrRev (your_string, "_")
returns position of the last underscore.

InStrRev (your_string, "_", InStrRev (your_string, "_") - 1)
returns position of the second to last underscore.

Mid(your_string, InStrRev (your_string, "_", InStrRev (your_string, "_") - 1) + 1, InStrRev (your_string, "_") - InStrRev (your_string, "_", InStrRev (your_string, "_") - 1) - 1)
returns what you need. :)

Thank you,
PW
0
 
LVL 28

Accepted Solution

by:
bdreed35 earned 1000 total points
ID: 16253069
A slightly simpler formula would make use of the split function:

local stringvar array batch := split({table.field},"_");
batch[ubound(batch)-1]
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16254193
Both are good answers.

mlmcc
0
 
LVL 17

Author Comment

by:MIKE
ID: 16484288
Thank you...I will use the above suggestions.... this project has been set back, but I can use the above suggestions.

THANKS
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

810 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