On Wed, Aug 5, 2009 at 9:08 AM, Christopher
Bodnar<[email protected]> wrote:
> This does exactly what I want it to do, for the “{“ character:
> myRegExp.Pattern = "[^{]*\{([^}]*)\}"
> I want the exact same function, but for the double quote character.

  First, an optimization.  The above pattern, expanded with whitespace
for clarity, is:

        [^{]*   \{   (    [^}]*   )   \}

  Translated to English: Zero-or-more characters which are not an
opening-brace, followed by opening-brace, followed by a grouping of
zero-or-more characters which are not a closing-brace, followed by a
closing-brace.

  I'm pretty sure you don't need that leading "zero-or-more characters
which are not an opening-brace" part.  Regular expressions use partial
matching by default.  So unless you anchor the pattern (start with ^
and/or end with $), there's no point.  So here's a slightly simpler
version of your pattern:

        \{   (    [^}]*   )   \}

  Translated to English: An opening-brace, followed by a grouping of
zero-or-more characters which are not a closing-brace, followed by a
closing-brace.

  So to do the same for a double-quote:

        "   (   [^"]   )   "

  Back in VB syntax:

        myRegExp.Pattern =      """([^""])"""

  This assumes quotes are always balanced and never nested.  You can't
cope with that kind of complexity with standard regular expression
syntax.

-- Ben

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

Reply via email to