View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.programming
[email protected] EagleOne@discussions.microsoft.com is offline
external usenet poster
 
Posts: 391
Default "String" manipulation for a Case clause

Excellent! Thanks

Ron Rosenfeld wrote:

On Sat, 09 May 2009 10:51:20 -0400, wrote:

re.Pattern = "(^|[-+/*^=])\b\d*\.?\d+\b"


Here is a formal explanation:

======================================
Extract Constants

(^|[-+/*^=])\b\d*\.?\d+\b

Match the regular expression below and capture its match into backreference
number 1 «(^|[-+/*^=])»
Match either the regular expression below (attempting the next alternative
only if this one fails) «^»
Assert position at the beginning of the string «^»
Or match regular expression number 2 below (the entire group fails if this
one fails to match) «[-+/*^=]»
Match a single character present in the list “-+/*^=” «[-+/*^=]»
Assert position at a word boundary «\b»
Match a single digit 0..9 «\d*»
Between zero and unlimited times, as many times as possible, giving back as
needed (greedy) «*»
Match the character “.” literally «\.?»
Between zero and one times, as many times as possible, giving back as needed
(greedy) «?»
Match a single digit 0..9 «\d+»
Between one and unlimited times, as many times as possible, giving back as
needed (greedy) «+»
Assert position at a word boundary «\b»


Created with RegexBuddy
======================================

We are not using the backreferences. The parentheses are used for grouping
purposes.

A "word boundary" is a position that is between a "word character" and a
"non-word character". Word charactes include [A-Za-z0-9_]

Some of these references may be helpful (some may not still be valid, though):

Regular Expressions
http://www.regular-expressions.info/reference.html
http://support.microsoft.com/default...02&Product=vbb
http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx
http://msdn2.microsoft.com/en-us/library/ms974619.aspx
http://www.regex-guru.info/
--ron