#include <iostream>
#include <regex>
using namespace std;
int main() {
const std::regex pattern("[^a-zA-Z0-9.-_]");
std::string String = "!#!e-ma.il@boomer.com";
// std::regex_constants::icase
// std::string newtext = std::regex_replace( String, pattern, "X", std::regex_constants::format_first_only );
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
std::cout << newtext << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKSB7Cgljb25zdCBzdGQ6OnJlZ2V4IHBhdHRlcm4oIlteYS16QS1aMC05Li1fXSIpOwoJc3RkOjpzdHJpbmcgU3RyaW5nID0gIiEjIWUtbWEuaWxAYm9vbWVyLmNvbSI7CgkvLyBzdGQ6OnJlZ2V4X2NvbnN0YW50czo6aWNhc2UKCS8vIHN0ZDo6c3RyaW5nIG5ld3RleHQgPSBzdGQ6OnJlZ2V4X3JlcGxhY2UoIFN0cmluZywgcGF0dGVybiwgIlgiLCBzdGQ6OnJlZ2V4X2NvbnN0YW50czo6Zm9ybWF0X2ZpcnN0X29ubHkgKTsKCXN0ZDo6c3RyaW5nIG5ld3RleHQgPSBzdGQ6OnJlZ2V4X3JlcGxhY2UoIFN0cmluZywgcGF0dGVybiwgIiIsIHN0ZDo6cmVnZXhfY29uc3RhbnRzOjppY2FzZSk7CglzdGQ6OmNvdXQgPDwgbmV3dGV4dCA8PCBzdGQ6OmVuZGw7CglyZXR1cm4gMDsKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:10:92: error: no matching function for call to ‘regex_replace(std::__cxx11::string&, const regex&, const char [1], const std::regex_constants::syntax_option_type&)’
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/regex:62:0,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.h:2294:5: note: candidate: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type, class _St, class _Sa> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, std::regex_constants::match_flag_type)
regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.h:2294:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::__cxx11::basic_regex<char>’ and ‘const char*’)
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/bits/regex.h:2802:0,
from /usr/include/c++/6/regex:62,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.tcc:459:5: note: candidate: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)
regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.tcc:459:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::__cxx11::basic_regex<char>’ and ‘const char*’)
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/regex:62:0,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.h:2339:5: note: candidate: template<class _Rx_traits, class _Ch_type, class _St, class _Sa, class _Fst, class _Fsa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _Fst, _Fsa>&, std::regex_constants::match_flag_type)
regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.h:2339:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: mismatched types ‘const std::__cxx11::basic_string<_Ch_type, _Fst, _Fsa>’ and ‘const char [1]’
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/regex:62:0,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.h:2365:5: note: candidate: template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)
regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.h:2365:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: cannot convert ‘std::regex_constants::icase’ (type ‘const std::regex_constants::syntax_option_type’) to type ‘std::regex_constants::match_flag_type’
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/regex:62:0,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.h:2391:5: note: candidate: template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, std::regex_constants::match_flag_type)
regex_replace(const _Ch_type* __s,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.h:2391:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: mismatched types ‘const _Ch_type*’ and ‘std::__cxx11::basic_string<char>’
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^
In file included from /usr/include/c++/6/regex:62:0,
from prog.cpp:2:
/usr/include/c++/6/bits/regex.h:2417:5: note: candidate: template<class _Rx_traits, class _Ch_type> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)
regex_replace(const _Ch_type* __s,
^~~~~~~~~~~~~
/usr/include/c++/6/bits/regex.h:2417:5: note: template argument deduction/substitution failed:
prog.cpp:10:92: note: mismatched types ‘const _Ch_type*’ and ‘std::__cxx11::basic_string<char>’
std::string newtext = std::regex_replace( String, pattern, "", std::regex_constants::icase);
^