View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default How to extract capitalized group in text string

On Tue, 26 Aug 2008 20:22:00 -0700, newbie
wrote:

I didn't follow your instructions too well the first time. By going
INSERT/MODULE, it works. Now I found a different instance where some of the
text strings have more than one occurrence of 3 uppercase characters in
varying locations. The code returns the first instance from the left, whereas
I need the last instance in the string. (first from the right).

Claymore CEF GS Connect ETN GCE Asset Allocation (returns CEF, need GCE)


Glad you figured out where to place the code.

There are a variety of methods of changing this so it will pick up the LAST
instance.

One method is to change the pattern in the argument:

"\b[A-Z]{3}\b(?!.*\b[A-Z]{3}\b)"

That translates into a command to

return any three-character uppercase string
that is not followed by another three-character upper case string

So your formula would now look like:

=ReExtr(A1,"\b[A-Z]{3}\b(?!.*\b[A-Z]{3}\b)")



--ron