(C++) Hello Boost.Regex

January 17, 2018 ยท View on GitHub

Hello Boost.Regex is an extension of Hello World. Like Hello World, Hello Boost.Regex is a simple console application. Hello Boost.Regex, however, also requires the Boost library and to link against the Boost.Regex library.

The base code of Hello Boost.Regex is:

#include <iostream>
#include <boost/regex.hpp>

int main()
{
  std::string s = "Hello World";
  s = boost::regex_replace(s,boost::regex("World"),std::string("Boost"));
  std::cout << s << '\n';
}

Here are some detailed examples of Hello Boost.Regex, depending on IDE and operating system: