Named Group support for regular expressions in TR1?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DomoChan@gmail.com

    Named Group support for regular expressions in TR1?

    When I attempt to name a group in a regular expression under TR1, the
    library throws a non descriptive error "regular expression error".
    The numbered reference group works, as in /1 to reference the first
    group. However, any attempt to use (?<myGroup>expr ession) fails?

    Does anyone have any insight into this?

    Thanks!
    -Velik
  • mlimber

    #2
    Re: Named Group support for regular expressions in TR1?

    On Aug 10, 5:21 pm, DomoC...@gmail. com wrote:
    When I attempt to name a group in a regular expression under TR1, the
    library throws a non descriptive error "regular expression error".
    The numbered reference group works, as in /1 to reference the first
    group.  However, any attempt to use (?<myGroup>expr ession) fails?
    >
    Does anyone have any insight into this?
    How about minimal but complete code (and input) to reproduce the
    problem? Compare this FAQ on posting non-working code:



    Cheers! --M

    Comment

    • DomoChan@gmail.com

      #3
      Re: Named Group support for regular expressions in TR1?

      On Aug 11, 8:59 am, mlimber <mlim...@gmail. comwrote:
      On Aug 10, 5:21 pm, DomoC...@gmail. com wrote:
      >
      When I attempt to name a group in a regular expression under TR1, the
      library throws a non descriptive error "regular expression error".
      The numbered reference group works, as in /1 to reference the first
      group.  However, any attempt to use (?<myGroup>expr ession) fails?
      >
      Does anyone have any insight into this?
      >
      How about minimal but complete code (and input) to reproduce the
      problem? Compare this FAQ on posting non-working code:
      >

      >
      Cheers! --M
      Certainly...

      // Compiler Information
      Version 9.0.21022.8 RTM
      Microsoft .NET Framework
      Version 3.5
      Installed Edition: Enterprise
      Microsoft Visual C++ 2008 91899-153-0000007-60443
      // Operating System
      Windows Vista

      #include <string>
      using std::string;

      // This example should be compiled with visual studio 2008, with the
      TR1 update
      // TR1 Update Link :

      #include <regex>
      using namespace std::tr1;

      int main(int argc, char* argv[])
      {
      try
      {
      // this works
      regex pattern1( "<[\\?](.+)[\\?]>?" );
      // this fails
      regex pattern2( "<[\\?](?'groupName'.+ )[\\?]>?" );
      // so does this
      regex pattern3( "<[\\?](?<groupName>.+ )[\\?]>?" );
      }
      catch (std::exception & exc)
      {
      // shows up as "regular expression error", "unknown (?'groupName')
      would have been nice :/ oh well
      string dbg = exc.what();
      }

      return 0;
      }

      Comment

      • mlimber

        #4
        Re: Named Group support for regular expressions in TR1?

        On Aug 11, 7:04 pm, DomoC...@gmail. com wrote:
        On Aug 11, 8:59 am, mlimber <mlim...@gmail. comwrote:
        >
        On Aug 10, 5:21 pm, DomoC...@gmail. com wrote:
        >
        When I attempt to name a group in a regular expression under TR1, the
        library throws a non descriptive error "regular expression error".
        The numbered reference group works, as in /1 to reference the first
        group.  However, any attempt to use (?<myGroup>expr ession) fails?
        >
        Does anyone have any insight into this?
        >
        How about minimal but complete code (and input) to reproduce the
        problem? Compare this FAQ on posting non-working code:
        >>
        Cheers! --M
        >
        Certainly...
        >
        // Compiler Information
        Version 9.0.21022.8 RTM
        Microsoft .NET Framework
        Version 3.5
        Installed Edition: Enterprise
        Microsoft Visual C++ 2008   91899-153-0000007-60443
        // Operating System
        Windows Vista
        >
        #include <string>
        using std::string;
        >
        // This example should be compiled with visual studio 2008, with the
        TR1 update
        // TR1 Update Link :http://www.microsoft.com/downloads/d...d=D466226B-8DA...
        #include <regex>
        using namespace std::tr1;
        >
        int main(int argc, char* argv[])
        {
                try
                {
                        // this works
                        regex pattern1( "<[\\?](.+)[\\?]>?" );
                        // this fails
                        regex pattern2( "<[\\?](?'groupName'.+ )[\\?]>?" );
                        // so does this
                        regex pattern3( "<[\\?](?<groupName>.+ )[\\?]>?" );
                }
                catch (std::exception & exc)
                {
                        // shows up as "regular expression error", "unknown (?'groupName')
        would have been nice :/ oh well
                        string dbg = exc.what();
                }
        >
                return 0;
        >
        }
        Looking at the Dinkumware documentation, I don't see support for named
        groups in the RE grammar.



        Am I missing something?

        Cheers! --M

        Comment

        • Pete Becker

          #5
          Re: Named Group support for regular expressions in TR1?

          On 2008-08-10 17:21:17 -0400, DomoChan@gmail. com said:
          When I attempt to name a group in a regular expression under TR1, the
          library throws a non descriptive error "regular expression error".
          The numbered reference group works, as in /1 to reference the first
          group. However, any attempt to use (?<myGroup>expr ession) fails?
          >
          Named groups are not part of regular expressions in TR1 nor in C++0x.

          --
          Pete
          Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
          Standard C++ Library Extensions: a Tutorial and Reference
          (www.petebecker.com/tr1book)

          Comment

          Working...