¿is there a way to avoid duplicating the backslash? it's quite confusing.
When you say "^\{.*" it's saying match if the line starts with a open brace (it would take from beginning to end)
without the caret would be "\{.*" match if the line contains an open brace (it would take from the brace to the end)
The difference should be clear with the input "foo{bar}"
with the caret it would fail, without it match "{bar}"
> sm.size() == 0; // true
It would be nice if you provide a test case
@Cubbi: I'm using 4.8.2, so judging by your Coliru, I guess it's the compiler. As for C++ lateness to the regex game, I'm surprised regex isn't a core part of C. Looks like 4.9 is available to me, so that is nice.
This regex library has been available to C++ programmers as boost.regex since the year 2000, just 2 years after C++ was even standardized.
It then entered C++ as part of the TR1 library extensions spec (released 2007), and then merged into C++11 along with almost all of TR1. It's not C++ that's late, it's gcc.