Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost.Regex vs C++11 Regex

Could someone explain the differences between the two? Which would be better to learn right now? How would knowledge transfer from one to the other and vice-versa?

like image 911
flumpb Avatar asked Sep 28 '11 21:09

flumpb


People also ask

What is boost regex?

Boost. Regex allows you to use regular expressions in C++. As the library is part of the standard library since C++11, you don't depend on Boost. Regex if your development environment supports C++11.

Why is C++ regex so slow?

The current std::regex design and implementation are slow, mostly because the RE pattern is parsed and compiled at runtime. Users often don't need a runtime RE parser engine as the pattern is known during compilation in many common use cases. I think this breaks C++'s promise of ​“don't pay for what you don't use.”

What kind of regex does C++ use?

C++11 uses ECMAScript grammar as the default grammar for regex. ECMAScript is simple, yet it provides powerful regex capabilities.


1 Answers

The boost regex library made it into C++0x so I'm guessing it will slowly be removed from boost. However, using boost is nice because you can still use it with compilers without C++0x support. So it's really up to you.

like image 141
Ilia Choly Avatar answered Sep 30 '22 00:09

Ilia Choly