Question: I simply want to match "{". But don't know why giving this error:

> 
> 
> ```
> terminate called after throwing an instance of 'std::regex_error'
>   what():  regex_error
> Aborted (core dumped)
> 
> ```
> 
> 

Compilation on Ubuntu with g++ version 4.6.3

```
g++   -std=c++0x   a.c

```

Program
-------

```
#include<iostream>
#include<regex>

using namespace std;

main(int argc,char**argv){

        if (regex_match("{1}" , std::regex ("[{]"))) {
                cout<<"Hello World"<<endl;
        }

}

```

I've also checked the [ECMAScript](http://www.cplusplus.com/reference/regex/ECMAScript/) details and this regular expression should match. It also does not match when I use like : `std::regex ("\\{"))`

**What am I wrong?**

Answer: 
You need at [least gcc 4.9](https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions) to make regexps work with gcc, once you will have 4.9 version add `.*` to make it match the rest of the string:

```
if (regex_match("{1}" , std::regex ("[{].*"))) {
                                        ^^

```

<http://coliru.stacked-crooked.com/a/99e405e66906804d>
I have the same error with you! And my IDE is **Clion**,   
I choose the C++ version with Clion is C++17 and my test code is:

```
std::string pattern{ "http|hppts://\\w.*$" }; // url
std::regex re(pattern);
std::vector<std::string> str{ "http://blog.net/xxx", 
  "https://github.com/jasonhubs", "abcd://124.456",
   "abcdhttps://github.com/jasonhubs" 
 };
for (auto tmp : str) 
{
  bool ret = std::regex_search(tmp, re);
  if (ret) fprintf(stderr, "%s, can search\n", tmp.c_str());
  else fprintf(stderr, "%s, can not search\n", tmp.c_str());
}

```

and I solve it by updating the **gcc** and **g++**.  

1. `sudo yum install centos-release-scl yum-utils`
2. `sudo yum-config-manager --enable rhel-server-rhscl-7-rpms`
3. `sudo yum install devtoolset-7`
4. `scl enable devtoolset-7 bash`