fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4.  
  5. using namespace std;
  6.  
  7. int main () {
  8. regex rxWorld("world");
  9. const string text = "hello world!";
  10. const auto t0 = text.cbegin();
  11. smatch match;
  12. const bool ok = regex_search(text, match, rxWorld);
  13. cout << " text:'" << text
  14. << "' ok:" << ok
  15. << " size:" << match.size()
  16. << " pos:" << match.position()
  17. << " len:"<< match.length()
  18. << endl;
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/tr1_impl/regex:2257:5: warning: inline function 'bool std::regex_search(_Bi_iter, _Bi_iter, std::match_results<_Bi_iter, _Allocator>&, const std::basic_regex<_Ch_type, _Rx_traits>&, std::regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >, _Allocator = std::allocator<std::sub_match<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> > > >, _Ch_type = char, _Rx_traits = std::regex_traits<char>, std::regex_constants::match_flag_type = std::bitset<11u>]' used but never defined
/home/V1FoTz/ccHkj6Nu.o: In function `main':
prog.cpp:(.text+0x4f): undefined reference to `std::basic_regex<char, std::regex_traits<char> >::_M_compile()'
prog.cpp:(.text+0xd7): undefined reference to `bool std::regex_search<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, char, std::regex_traits<char> >(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&, std::basic_regex<char, std::regex_traits<char> > const&, std::bitset<11u>)'
collect2: ld returned 1 exit status
stdout
Standard output is empty