Pattern matching with boost

Discussion in 'C++' started by Dave, Dec 12, 2005.

  1. Dave

    Dave Guest

    Hello all,

    Using Boost (probably regular expressions), how would I check that a
    std::string conforms to the pattern "Software Version:
    [0-9]+-[0-9]+-[0-9]+-[0-9]+"? For example, the following string should be
    accepted:

    Software Version: 2-2-8-10

    but this should not:

    Software Version: 2-2-8-A

    I'd like to do something akin to the following:

    if (!boost::string_matches_pattern(str, "Software Version:
    [0-9]+-[0-9]+-[0-9]+-[0-9]+"))
    cout << "Bad software version!\n";

    Thanks in advance,
    Dave
    Dave, Dec 12, 2005
    #1
    1. Advertising

  2. Dave

    David Harmon Guest

    On Mon, 12 Dec 2005 14:54:29 -0700 in comp.lang.c++, "Dave"
    <> wrote,
    >I'd like to do something akin to the following:
    >
    >if (!boost::string_matches_pattern(str, "Software Version:


    Where does that "string_matches_pattern" function come from?
    Is it supposed to be another name for "regex_match" from the boost
    regex package?
    David Harmon, Dec 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Latter
    Replies:
    2
    Views:
    2,882
    Julie
    May 17, 2004
  2. Steve Knight
    Replies:
    2
    Views:
    739
    Steve Knight
    Oct 10, 2003
  3. Toby Bradshaw
    Replies:
    6
    Views:
    1,712
    Kai-Uwe Bux
    Jun 2, 2006
  4. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    216
    Marc Bissonnette
    Jan 13, 2004
  5. Bobby Chamness
    Replies:
    2
    Views:
    207
    Xicheng Jia
    May 3, 2007
Loading...

Share This Page