View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Regular Expression for cell address

On Tue, 2 Jan 2007 20:16:31 -0500, "M. Authement" wrote:

Thanks Ron.

Does that mean that the potential cell address MUST be preceeded by one of
the characters in the first part of the expression in order for the rest of
the expression to be true (found in a string)?


Yes



Also, any thoughts on making the row number expression more robust?


Depending on how you are implementing this, it might be simpler to capture the
digit string and then test it to see if it is in the range.

You can do it with a regex, but the one I came up with is messy:

\b(([1-9]\d{0,3})|([1-5]\d{4})|(6[0-4]\d{3})|(65[0-4]\d{2})|(655[0-2]\d)|(6553[0-6]))\b


Maybe someone has a simpler one.

Oh, you can combine some of the stuff at the end (the 65's), but you'd still
have just as much alternation and it would be more difficult to understand.

Also, you'd need to change the starting word boundary token (\b) to represent
your column letters optionally followed by the "$".


--ron