Boost is a free source code library for C++. After downloading and unzipping, you need to run the bootstrap batch file or script and then run b2 --with-regex to compile Boost's regex library. Then add the folder into which you unzipped Boost to the include path of your C++ compiler. Add the stage\lib subfolder of that folder to your linker's library path. Then you can add #include <boost/regex.hpp> to your C++ code to make use of Boost regular expressions.
If you use C++Builder, you should download the Boost libraries for your specific version of C++Builder from Embarcadero. The version of Boost you get depends on your version of C++Builder and whether you're targeting Win32 or Win64. The Win32 compiler in XE3 through XE8, and the classic Win32 compiler in C++Builder 10 Seattle through 10.1 Berlin are all stuck on Boost 1.39. The Win64 compiler in XE3 through XE6 uses Boost 1.50. The Win64 compiler in XE7 through 10.1 Berlin uses Boost 1.55. The new C++11 Win32 compiler in C++Builder 10 and later uses the same version of boost as the Win64 compiler.
This website covers Boost 1.38, 1.39, and 1.42 through the latest 1.62. Boost 1.40 introduced many new regex features borrowed from Perl 5.10. But it also introduced some serious bugs that weren't fixed until Boost 1.42. So we completely ignore Boost 1.40 and 1.41. We still cover Boost 1.38 and 1.39 (which have identical regex features) because the classic Win32 C++Builder compiler is stuck on this version. If you're using another compiler, you should definitely use Boost 1.42 or later to avoid what are now old bugs. You should preferably use Boost 1.47 or later as this version changes certain behaviors involving backreferences that may change how some of your regexes behave if you later upgrade from pre-1.47 to post-1.47.
In practice, you'll mostly use the Boost's ECMAScript grammar. It's the default grammar and offers far more features that the other grammars. Whenever the tutorial on this website mentions Boost without mentioning any grammars then what is written applies to the ECMAScript grammar and may or may not apply to any of the other grammars. You'll really only use the other grammars if you want to reuse existing regular expressions from old POSIX code or UNIX scripts.
|Dot matches line breaks||never||default||never||option|
|Anchors match at line breaks||always||default||option||option|
|Line break characters||CR, LF||CR, LF, FF, NEL, LS, PS||CR, LF, LS, PS||LF|
|Backreferences to non-participating groups||Match empty string||fail since 1.47||Match empty string||fail|
|Empty character class||Fails to match||Not possible||Fails to match||Not possible|
|Named capture||no||.NET syntax||no||.NET & Python syntax|
|Atomic groups backtrack capturing groups||n/a||no||n/a||YES|
|Start and end of word boundaries||no||YES||no||no|
|Standard POSIX classes||YES||YES||no||YES|
|Single letter POSIX classes||no||YES||no||no|
Did this website just save you a trip to the bookstore? Please make a donation to support this site, and you'll get a lifetime of advertisement-free access to this site! Credit cards, PayPal, and Bitcoin gladly accepted.
Page URL: https://www.regular-expressions.info/boost.html
Page last updated: 30 June 2017
Site last updated: 22 February 2018
Copyright © 2003-2018 Jan Goyvaerts. All rights reserved.
|Languages & Libraries|
|Visual Basic 6|
|XQuery & XPath|
|Regular Expressions Quick Start|
|Regular Expressions Tutorial|
|Replacement Strings Tutorial|
|Applications and Languages|
|Regular Expressions Examples|
|Regular Expressions Reference|
|Replacement Strings Reference|
|About This Site|
|RSS Feed & Blog|