Perl/Python regular expressions vs. Boost.regex?

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

    Perl/Python regular expressions vs. Boost.regex?

    A colleague wrote a C++ library here at work which uses the Boost.regex
    library. I quickly discovered an apparent problem with how it searches.
    Unlike re.match the regex_match function in that library effectively anchors
    the match at both the start and the end. Can other people confirm this?

    Thx,

    Skip Montanaro
  • Rob Williscroft

    #2
    Re: Perl/Python regular expressions vs. Boost.regex?

    wrote in news:mailman.29 06.1224773327.3 487.python-list@python.org in
    comp.lang.pytho n:
    A colleague wrote a C++ library here at work which uses the
    Boost.regex library. I quickly discovered an apparent problem with
    how it searches. Unlike re.match the regex_match function in that
    library effectively anchors the match at both the start and the end.
    Can other people confirm this?
    >
    Thx,
    >
    Skip Montanaro
    >
    Quoting from : <url:http://www.boost.org/doc/libs/1_36_
    0/libs/regex/doc/html/boost_regex/ref/regex_match.htm l>

    <quote>
    Important

    Note that the result is true only if the expression matches the whole of
    the input sequence. If you want to search for an expression somewhere
    within the sequence then use regex_search. If you want to match a prefix of
    the character string then use regex_search with the flag match_continuou s
    set.

    </quote>

    So yes it does.

    Rob.
    --

    Comment

    • skip@pobox.com

      #3
      Re: Perl/Python regular expressions vs. Boost.regex?


      RobQuoting from : <url:http://www.boost.org/doc/libs/1_36_0/libs/regex/doc/html/boost_regex/ref/regex_match.htm l>

      Rob<quote>
      RobImportant

      RobNote that the result is true only if the expression matches the
      Robwhole of the input sequence. If you want to search for an
      Robexpression somewhere within the sequence then use regex_search. If
      Robyou want to match a prefix of the character string then use
      Robregex_search with the flag match_continuou s set.

      Rob</quote>

      RobSo yes it does.

      Thanks. I'll try and convince my colleague to use regex_search instead of
      regex_match.

      Skip

      Comment

      Working...