Boost logo

Boost Users :

Subject: [Boost-users] boost 1.50 unable to make regex_match to work
From: MAURICE Jean (jean.maurice_at_[hidden])
Date: 2016-10-27 05:56:48


1) Hi Kai, I wrote
   const_iterator BOOST_REGEX_CALL end()const
   {
      // JME 27/10/16 pour savoir si on passe là, je crée une division par 0 en
      // esperant que le compilateur ne la détecte pas
      int ijme1, ijme2;
      ijme2 = 1;
      ijme1 = 2;
      --ijme2;
      ijme1 = ijme1 / ijme2;
      return (!this->m_status ? 0 : this->m_expression + this->m_expression_len);
     // return (this->m_status ? 0 : this->m_expression + this->m_expression_len); JME 26/10/16
   }

Hoping the divide by 0 error would be thrown but it never appears. So I don't think this bug is annoying me.

2) As I am new to boost and regex I tried a simple test :
      string pattern = "GHI+";
      string chaineatester = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
      boost::regex boost_pattern( pattern );
      boost::smatch what;
      int errjme = boost::regex_match( chaineatester, what, boost_pattern );
      if (errjme == 1)
      {
            *outputLog << "test 1: GHI+ a été trouvé" << endl;
      }
      else
      {
            *outputLog << "test 1: GHI+ n'a pas été trouvé" << endl;
      // what[0] contains the whole string
      // what[1] contains the response code
      // what[2] contains the separator character
      // what[3] contains the text message.
            *outputLog << " what[0]:" << what[0] << endl \
                  << " what[1]:" << what[1] << endl \
                  << " what[2]:" << what[2] << endl \
                  << " what[3]:" << what[3] << endl;
      }
      string pattern2 = "GHI";
      boost::regex boost_pattern2( pattern2 );
      errjme = boost::regex_match( chaineatester, what, boost_pattern2 );
      if (errjme == 1)
      {
            *outputLog << "test 1bis: GHI a été trouvé" << endl;
      }
      else
      {
            *outputLog << "test 1bis: GHI n'a pas été trouvé" << endl;
            *outputLog << " what[0]:" << what[0] << endl \
                  << " what[1]:" << what[1] << endl \
                  << " what[2]:" << what[2] << endl \
                  << " what[3]:" << what[3] << endl;
      }

                And here is what I get :

test 1: GHI+ n'a pas été trouvé
  what[0]:
  what[1]:
  what[2]:
  what[3]:
test 1bis: GHI n'a pas été trouvé
  what[0]:
  what[1]:
  what[2]:
  what[3]:

What am I doing wrong ?

Jean



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net