I just started using c++ expression and couldn't get rid of this error. I am also confused why in some c++ regex examples, people use \\s \\{ \\w
instead of just \s \{ \w
?
#include<iostream>
#include<regex>
using namespace std;
int main()
{
string s1("{1,2,3}");
string s2("{}");
regex e("\\{(\\d,?)+\\}", regex_constants::extended);
if (regex_match(s1,e))
cout << "yes" << endl;
}
Error info:
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Aborted (core dumped)
Edit: I answer @Lightness Races in Orbit's question here regarding the complier:
dpkg --list | grep compiler
ii g++ 4:4.8.2-1ubuntu6 amd64 GNU C++ compiler
ii g++-4.8 4.8.4-2ubuntu1~14.04 amd64 GNU C++ compiler
ii gcc 4:4.8.2-1ubuntu6 amd64 GNU C compiler
ii gcc-4.8 4.8.4-2ubuntu1~14.04 amd64 GNU C compiler
ii gfortran 4:4.8.2-1ubuntu6 amd64 GNU Fortran 95 compiler
ii gfortran-4.8 4.8.4-2ubuntu1~14.04 amd64 GNU Fortran compiler
ii hardening-includes 2.5ubuntu2.1 all Makefile for enabling compiler flags for security hardening
ii libllvm3.4:amd64 1:3.4-1ubuntu3 amd64 Modular compiler and toolchain technologies, runtime library
ii libplexus-archiver-java 1.2-1 all Archiver plugin for the Plexus compiler system
ii libprotoc8:amd64 2.5.0-9ubuntu1 amd64 protocol buffers compiler library
ii libxkbcommon-dev 0.4.1-0ubuntu1 amd64 library interface to the XKB compiler - development files
ii libxkbcommon0:amd64 0.4.1-0ubuntu1 amd64 library interface to the XKB compiler - shared library
ii protobuf-c-compiler 0.15-1build1 amd64 protocol buffers C compiler