Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex: boost::xpressive vs boost::regex

I wanted to do some regular expressions in C++ so I looked on the interwebz (yes, I am an beginner/intermediate with C++) and found this SO answer.

I really don't know what to choose between boost::regex and boost::xpressive. What are the pros/cons?

I also read that boost::xpressive opposed to boost::regex is a header-only library. Is it hard to statically compile boost::regex on Linux and Windows (I almost always write cross-platform applications)?

I'm also interested in comparisons of compile time. I have a current implementation using boost::xpressive and I'm not too content with the compile times (but I have no comparisons to boost::regex).

Of course I'm open for other suggestions for regex implementations too. The requirements are free (as in beer) and compatible with http://nclabs.org/license.php.

like image 455
orlp Avatar asked May 12 '11 18:05

orlp


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. You can use identically named classes and functions in the namespace std if you include the header file regex .

Is std :: regex 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.


1 Answers

One fairly important difference is that Boost Regex can support linking to ICU for Unicode support (character classes, etc) Boost Regex ICU Support.

As far as I can tell, Boost Xpressive doesn't have this kind of support built-in.

like image 130
wjl Avatar answered Sep 20 '22 18:09

wjl