Monthly Archives: March 2013

Using Rcpp with Boost.Regex for regular expression

March 1, 2013
By
Using Rcpp with Boost.Regex for regular expression

Gabor asked about Rcpp use with regular expression libraries. This post shows a very simple example, based onone of the Boost.RegEx examples. We need to set linker options. This can be as simple as Sys.setenv("PKG_LIBS"="-lboost_regex") With that, the following example can be built: // cf www.boost.org/doc/libs/1_53_0/libs/regex/example/snippets/credit_card_example.cpp #include <Rcpp.h> #include <string> #include <boost/regex.hpp> bool validate_card_format(const std::string& s) { static const boost::regex e("(\\d{4}){3}\\d{4}"); ...

Read more »