perl-like regular expression parsing for C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Chiu

    perl-like regular expression parsing for C++

    Hi:

    I'm used to perl's regular expression string matching, e.g.

    if ($line =~ /^(.*)[ \t]+(.*)$/) {
    $name = $1;
    $age = $2;
    ....

    I want to do this in C++ using gcc under linux and cygwin - what would
    a good solution look like?

    Mr. B
  • Noah Roberts

    #2
    Re: perl-like regular expression parsing for C++

    Bill Chiu wrote:[color=blue]
    > Hi:
    >
    > I'm used to perl's regular expression string matching, e.g.
    >
    > if ($line =~ /^(.*)[ \t]+(.*)$/) {
    > $name = $1;
    > $age = $2;
    > ...
    >
    > I want to do this in C++ using gcc under linux and cygwin - what would
    > a good solution look like?[/color]

    It would look like a third party library probably found on freshmeat.

    NR
    [color=blue]
    >
    > Mr. B[/color]


    Comment

    • Ron Natalie

      #3
      Re: perl-like regular expression parsing for C++


      "Bill Chiu" <billchiu@despa mmed.com> wrote in message news:94f9726d.0 309111348.4b994 3d@posting.goog le.com...[color=blue]
      > Hi:
      >
      > I'm used to perl's regular expression string matching, e.g.
      >
      > if ($line =~ /^(.*)[ \t]+(.*)$/) {
      > $name = $1;
      > $age = $2;
      > ..[/color]

      The standard library doesn't help, but there are some good regular expression
      classes out there including the one in boost (http://www.boost.org).


      Comment

      • Jon Bell

        #4
        Re: perl-like regular expression parsing for C++

        In article <3F60EF1D.70704 04@dontemailme. com>,
        Noah Roberts <nroberts@donte mailme.com> wrote:[color=blue]
        >Bill Chiu wrote:[color=green]
        >>
        >> I'm used to perl's regular expression string matching, e.g.[/color][/color]
        [snip][color=blue][color=green]
        >> I want to do this in C++ using gcc under linux and cygwin - what would
        >> a good solution look like?[/color]
        >
        >It would look like a third party library probably found on freshmeat.[/color]

        A Google search on "C++ regular expression library" turns up some
        candidates.

        --
        Jon Bell <jtbellap8@pres by.edu> Presbyterian College
        Dept. of Physics and Computer Science Clinton, South Carolina USA

        Comment

        • Uwe Schnitker

          #5
          Re: perl-like regular expression parsing for C++

          "Ron Natalie" <ron@sensor.com > wrote in message news:<3f60f095$ 0$51879$9a6e19e a@news.newshost ing.com>...[color=blue]
          > "Bill Chiu" <billchiu@despa mmed.com> wrote in message news:94f9726d.0 309111348.4b994 3d@posting.goog le.com...[color=green]
          > > Hi:
          > >
          > > I'm used to perl's regular expression string matching, e.g.
          > >
          > > if ($line =~ /^(.*)[ \t]+(.*)$/) {
          > > $name = $1;
          > > $age = $2;
          > > ..[/color]
          >
          > The standard library doesn't help, but there are some good regular expression
          > classes out there including the one in boost (http://www.boost.org).[/color]

          One nice thing - among others - about the boost regex library is that
          something quite similiar has been voted to go into the forthcoming
          Library Technical Report, which is the first step to become part
          of the next revision of the C++ standard.

          It will take several years until this revision will become official, but
          hopefully compiler and library providers will include them when it will be
          inofficially decided.

          Comment

          Working...