boost::regex_replace issue

Discussion in 'C++' started by Yahooooooooo, Jan 30, 2007.

  1. Yahooooooooo

    Yahooooooooo Guest

    Just practicing BOOST regular expressions....giving errors...
    -- wanted to replace SPACE with NULL.


    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include <string>
    #include <iterator>
    #include <boost/regex.hpp>
    #include <fstream>
    #include <iostream>

    using namespace std;
    boost::regex rex1;
    extern const char* pre_expression= " ";
    extern const char* pre_format="";

    int main(void)
    {
    string line;
    //boost::regex rex1(" ",boost::regex::perl|boost::regex::icase);
    rex1.assign(pre_expression);
    boost::regex rex2;

    ifstream fh("/tmp/log.conf");
    getline(fh,line);
    cout << line << endl;

    std::eek:stringstream osstr(std::ios::eek:ut);
    std::eek:stream_iterator<char,char> oi(osstr);


    boost::regex_replace(oi,line.begin(),line.end(),rex1,pre_format,boost::
    match_default | boost::format_all);

    getline(fh,line);
    cout << line << endl;
    fh.close();
    return 1;
    }



    ##### g++ -o runme -ftemplate-depth-100 -I/home/azmath/dev/
    boost_1_33_1/ -DBOOST_USER_CONFIG="</home/azmath/dev/boost_1_33_1/
    boost/config/user.hpp>" -lboost_regex-gcc-d-1_33_1 classreadfile.cc

    In file included from /home/azmath/dev/boost_1_33_1/boost/regex/v4/
    regex.hpp:55,
    from /home/azmath/dev/boost_1_33_1/boost/regex.hpp:
    31,
    from classreadfile.cc:6:
    /home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp: In
    instantiation of
    `boost::regex_traits<char,boost::cpp_regex_traits<char> >':

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp:
    38: instantiated from here

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/char_regex_traits.hpp:38:
    base class `boost::cpp_regex_traits<char>' has incomplete type

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp: In
    instantiation of
    `boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trai
    ts<char> > >':

    classreadfile.cc:14: instantiated from here

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:186: no
    type named `size_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:187: no
    type named `string_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:202: no
    type named `locale_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:530: no
    type named `locale_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:530: no
    type named `locale_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:339: no
    type named `locale_type' in `struct
    boost::regex_traits<char,boost::cpp_regex_traits<char> >'

    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp: In
    method `class
    boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trait
    s<char> > > &
    boost::basic_regex<char,boost::regex_traits<char,boost::cpp_regex_trait
    s<char> > >::assign(const char *, unsigned int =
    boost::regex_constants::normal)':

    classreadfile.cc:26: instantiated from here
    /home/azmath/dev/boost_1_33_1/boost/regex/v4/basic_regex.hpp:239: no
    method `boost::regex_traits<char,boost::cpp_regex_traits<char>
    >::length'


    classreadfile.cc: In function `int main()':
    classreadfile.cc:48: wrong number of template arguments (2, should be
    1)
    /usr/include/g++/stl_iterator.h:875: provided for `template <class
    _Tp> ostream_iterator<_Tp>'
    classreadfile.cc:48: confused by earlier errors, bailing out
     
    Yahooooooooo, Jan 30, 2007
    #1
    1. Advertising

  2. Yahooooooooo

    David Harmon Guest

    On 29 Jan 2007 21:55:08 -0800 in comp.lang.c++, "Yahooooooooo"
    <> wrote,
    >Just practicing BOOST regular expressions....giving errors...


    Your example compiles fine for me with MSVC 7, Windows.
    You might want to try the Boost forums.
     
    David Harmon, Jan 31, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    1,860
  2. Replies:
    6
    Views:
    408
    Robbie Hatley
    Jul 14, 2006
  3. Yahooooooooo

    boost::regex_replace compiler error

    Yahooooooooo, Jan 22, 2007, in forum: C++
    Replies:
    3
    Views:
    478
  4. Replies:
    1
    Views:
    942
  5. Friedel Jantzen

    regex_replace()

    Friedel Jantzen, May 10, 2011, in forum: C++
    Replies:
    16
    Views:
    1,429
    James Kanze
    May 15, 2011
Loading...

Share This Page