Subject: [Boost-bugs] [Boost C++ Libraries] #3458: Xpressive Library - sub_match does not work on some occasions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-16 23:45:54
#3458: Xpressive Library - sub_match does not work on some occasions
---------------------------------------------------+------------------------
Reporter: Eric Schwarz <master.universe@â¦> | Owner: eric_niebler
Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: xpressive
Version: Boost 1.40.0 | Severity: Problem
Keywords: xpressive sub_match |
---------------------------------------------------+------------------------
Decoding a time and date string.
Dealing with dynamic regexes.
Code does compile but suspicious output when executed.
Regex does match, but submatches aren't like expected partially.
Actually all string compares should return "0" but don't.
For those which don't for me a "cout" of the submatch string was added.
#include <string>
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
using namespace std;
using namespace boost;
using namespace boost::xpressive;
int main()
{
/////////////////////////////////////////////
// Decode date and time
// 2009/09/14 05:30
//
sregex rex = sregex::compile(
"^(\\d{4})/(\\d{2})/(\\d{2})(\\s)(\\d{2})([:])(\\d{2})" );
smatch what;
if( regex_match( string("2009/09/14 05:30"), what, rex ) )
{
cout << "TAF file was generated on " << what.size() <<
endl;
cout << what[0].str().compare( string( "2009/09/14 05:30"
) ) << endl;
cout << what[1].str().compare( string( "2009" ) ) << endl;
cout << what[2].str().compare( string( "09" ) ) << endl;
cout << what[3].str().compare( string( "14" ) ) << endl;
cout << what[3].str() << endl;
cout << what[4].str().compare( string( " " ) ) << endl;
cout << what[4].str() << endl;
cout << what[5].str().compare( string( "05" ) ) << endl;
cout << what[5].str() << endl;
cout << what[6].str().compare( string( ":" ) ) << endl;
cout << what[7].str().compare( string( "30" ) ) << endl;
}
return 0;
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3458> 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:01 UTC