View Single Post
  #19   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Extracting a numbers from a text string

On Mon, 26 Feb 2007 11:22:08 -0800, IPerlovsky
wrote:

How would I extract a number (or series of numbers) using a single cell
formula from an alphanumeric text string that also contains spaces? One key
component of the number(s) in question, is that they have a space on either
side. See the example of the text string below:

"A 544646-BA CALIF UN1MM+ 5 7/1/2017 FSA 108.579 3.90 3.82 8 Aaa AAA"

In this example, I am trying to extract the number "8". However, there is
also the number "5", which appears first, and that I want to avoid
extracting. Additionally, the formula should be able to extract any number,
not specific to "8" or "5". This formula should always skip the first single
number surrounded by spaces ("5" in this example) and extract the second
number(s) ("8" in this example).


Looking at your examples and trying to read a bit between the lines, it appears
as if the integer number you are trying to extract can also be described as the
last integer surrounded by spaces in the string.

That being the case, here is one solution:

Download and install Longre's free and easily distributable morefunc.xll add-in
from http://xcell05.free.fr/

Then use this "regular expression" formula:

=REGEX.MID(A1,"(?<=\s)\d+(?=\s)",-1)


--ron