Using Regular Expressions with Boost in C++

Boost is a free source code library for C++. The <boost/regex> header provides various template classes that are very flexible, but not the easiest to use. Fortunately, RegexBuddy knows exactly which template instantiations and which flags you need.

RegexBuddy supports Boost 1.38, 1.39, and 1.42 through the latest 1.65. Boost 1.40 and 1.41 are not supported as these have some fundamental bugs. Boost 1.38 and 1.39 (which have identical regex features) are supported 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.

See How Easy Coding with Regexes Can Be

First, use RegexBuddy to define a regex or retrieve a regexp saved in a RegexBuddy library. Rely on RegexBuddy's clear regex analysis, which is constantly updated as you build the pattern, rather than dealing with the cryptic regex syntax on your own. Detailed help on that syntax is always only a click away.

Boost supports six different regex flavors or grammars. RegexBuddy fully supports all of them. Just tell RegexBuddy which grammar to use to create and test your regular expression. You can convert regexes from one grammar to another. You can even convert regexes that were created for any other regex library or programming language to any of the six boost::regex grammars.

If you're writing a code library that needs to work with multiple versions of Boost or if you're migrating your code from one version of Boost to another, Compare your regex between as many versions of Boost as you like. RegexBuddy knows all the features and all the bugs Boost 1.38, 1.39, and 1.42 through 1.65.

Boost behaves differently when processing strings or arrays of char versus wchar_t. With RegexBuddy you can compare and convert between the two variants for all the supported compilers via the separate application choices for boost::regex and boost::wregex.

If you created a new regular expression, test and debug it in RegexBuddy before using it in your source code. Test each regex in RegexBuddy's safe sandbox without risking precious data. Quickly apply the regex to a wide variety of input and sample data, without having to produce that input through your application.

Finally, let RegexBuddy generate a source code snippet that you can copy and paste directly into whichever IDE or C/C++ code editor you use. Just choose what you want to use the regex for, and a fully functional code snippet is ready. You can change the names of variables and parameters to suit your naming style or the current situation, which RegexBuddy automatically remembers.

Don't bother trying to remember all the boost::regex and boost::wregex template instantiations, their member functions, and the parameters they require. And don't worry about properly escaping backslashes and quotes. Just tell RegexBuddy what you want to do, and you will get the proper C++ code straight away.

Using regular expressions in C++ with boost::regex
Using regular expressions in C++ with boost::wregex

Let RegexBuddy Make Regex Easy for You