pcre objects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gavoa2
    New Member
    • Aug 2008
    • 3

    pcre objects

    Hi all
    Can you please help me with this issue ?
    I am trying to create - pcrecpp objects and get them into a vector in order to check them later with an iterator :



    ifstream Input;
    string Line;
    string URL;
    typedef vector<const pcrecpp::RE*> URL_list;
    URL_list m_URL_list;

    while(Input) {

    getline(Input,L ine);
    m_URL_list.push _back(( new pcrecpp::RE(Lin e) ) ) ;
    }

    // trying to run with an iterator on all the lines
    // and see if I get matches
    //the objects in the file was
    // .*cnn.com , .*cnn.com.* , cnn.com*.
    //but none of the was found equal to the list below
    // can you please tell me if I built the objects and the iterator ok ?
    // when I am doing (pcrecpp::RE(". *cnn.com").Full Match... it finds the matches


    URL_list::itera tor it = m_URL_list.begi n(),
    ite = m_URL_list.end( );

    for(; it != ite; ++it) //PartialMatch looks for the word any where
    {
    if((*it)->FullMatch("cnn .com"))
    printf("###MATC HES cnn.com \n" );

    if((*it)->FullMatch("ima ges.cnn.com"))
    printf("###MATC HES images.cnn.com \n" );}

    if((*it)->FullMatch("cnn .com/images"))
    printf("###MATC HES cnn.com/imagesON1 \n" );

    if((*it)->FullMatch("bc. cnn.com/images"))
    printf("###MATC HES bc.cnn.com/images ON1 \n" );
    }


    //Thanks for your help
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I assume you have stepped though this code using your debugger? Yes?

    Comment

    • gavoa2
      New Member
      • Aug 2008
      • 3

      #3
      Originally posted by weaknessforcats
      I assume you have stepped though this code using your debugger? Yes?
      I am using linux with no debugger I am using the prints as my debugger as you can see in the code...
      and it doesnt print anything..

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        If you are running linux, you should have gdb, a good debugger. There's lots of tutorials/manuals for it available online.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          You have to step through FullMatch and see what's going on.

          Use that debugger and do not put print statements in your code for debugging. When you put those print statements in there, you have to take them out. When you take them out you could a) forget one or b) take out a print that's supposed to be there. In any case, the removal has changed the source code. Now you are not sure that it still works. So you have to debug it again. So you have to put in print statements again....

          Just learn your debugger.

          Comment

          • gavoa2
            New Member
            • Aug 2008
            • 3

            #6
            Thanks !!
            I will try it.

            Comment

            Working...