September 10, 200223 yr I need to parse out a 5 digit number out of a text string. It can appear anywhere within the text so it can't be a left or right word calc. Is there a way to parse a 5 digit number out? It would seem simple. Also it would be nice to be able to get the 3 letter code following the number. Some example strings. zJobs1 Archive:34939-oul11-2:IT - PDF Folder: zRip2Disk Archive:35727-HOR-2(RSIdata):Default Job:Primex12.eps:Stats: Anchor:55587-afp-02
September 10, 200223 yr Try this: Middle(TheString, Position( Substitute(Substitute(Substitute(Substitute(Substitute( Substitute(Substitute(Substitute(Substitute(Substitute(TheString, "0", "~"), "1", "~"), "2", "~"), "3", "~"), "4", "~"), "5", "~"), "6", "~"), "7", "~"), "8", "~"), "9", "~"), "~~~~~", 1, 1), 5)
September 10, 200223 yr Author Works perfectly. By increasing the last digit I can also get it to grab the 3 letter code and then strip that out by using middle words. If I wanted to just grab the 3 digit code seperately could that be done. I tried reading through the calc to duplicate it to do that and got lost. Thank you Very Much. Wayne
September 11, 200223 yr What this formula does is replace all the numerals with the squiggle "~" character and then search for starting position of five squiggles in a row which is the starting position of the five digit number. To get the 3 character suffix, just add 6 to the position, and change the length to 3 as follows: Middle(TheString, 6+Position( Substitute(Substitute(Substitute(Substitute(Substitute( Substitute(Substitute(Substitute(Substitute(Substitute(TheString, "0", "~"), "1", "~"), "2", "~"), "3", "~"), "4", "~"), "5", "~"), "6", "~"), "7", "~"), "8", "~"), "9", "~"), "~~~~~", 1, 1), 3) Personally, I would just use this to get the whole 9 characters and then process that separately. Considering speed issues, since this is a rather complicated formula, why use it more than once when you can grab the important chunk of 9 characters, and then parse it with much simpler formulas.
September 11, 200223 yr Author That sounds like a good way to go. I wasn't sure if getting all the characters at once then parsing would be faster or not. It makes sense only to run the large parse for 1 calculation. Thanks, Wayne
Create an account or sign in to comment