View Single Post
  #46  
Old July 20th, 2009, 09:16 PM posted to microsoft.public.excel.misc
Eric_NY
external usenet poster
 
Posts: 88
Default Need formula to extract a numeric value from a free-format tex

I see what you mean.

The problem I was getting was that the "\b" was excluding some cases that I
found in my data (such as "SR1234567" and "1234567remedy"). there were other
cases with a non-space immediately adjacent to the 7-digit sequence. So I
just took out the "\b" part of the pattern.

(I was also embarrassed when I presented the results and realized that my
7-digit numbers actually began at 987262 - i.e., a 6-digit number, so not all
of them were in fact 7 digits. So my logic was wrong and I missed one that I
should have found.)

But for my current purposes this is good enough. I'm doing a one-time
analysis of several thousand records, and don't need to develop a permanent,
perfect solution. I revised the regular expression to be "good enough"
considering the data that I saw in front of me.

Many thanks for your help.


"Ron Rosenfeld" wrote:

On Mon, 20 Jul 2009 07:48:01 -0700, Eric_NY
wrote:

I used the regex solution that Ron Rosenfeld suggested, and adjusted the
regular expression by removing the "\b" before and after the "\d{7}".



If you remove the "\b"'s, then the regex solution will return, for example, 7
digit portions of 8 digit numbers; or if you have an entry like NH123456789, it
will return 1234567. Is that what you want?
--ron