Re: [Boost-bugs] [Boost C++ Libraries] #3899: Regex: Bug in handling of "\Z"

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3899: Regex: Bug in handling of "\Z"
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-04 20:30:53


#3899: Regex: Bug in handling of "\Z"
-------------------------------------------------+--------------------------
 Reporter: Keith MacDonald <keith@…> | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: None
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
-------------------------------------------------+--------------------------

Comment(by Keith MacDonald <keith@…>):

 Here you go:
 {{{
 // cl /EHsc /IC:\Dev\boost_1_41_0 re.cpp /link
 /LIBPATH:C:\Dev\boost_1_41_0\stage\lib

 #include <string>
 #include <iostream>
 #include <boost/regex.hpp>

 int main()
 {
         std::string s = "1\r2\r\r";
         boost::regex re("\\Z");
         //boost::regex re("\\n*\\z");

         std::string s2 = regex_replace(s, re, "A");

         for (int i = 0; i < s2.length(); ++i) {
                 const char c = s2[i];

                 if (c == '\r')
                         std::cout << "\\r";
                 else if (c == '\n')
                         std::cout << "\\n";
                 else
                         std::cout << c;
         }

         return 0;
 }
 }}}

 This, when built with Visual Studio 2008 results in "1\r2A\rA\rA".

 The Perl documentation for \Z states that it works with "\n", not "\r",
 which is necessary for it to be equivalent to "\n*\z". My tests with perl
 5.10.1 confirm this behaviour.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3899#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC