From f55af780d9a6af6181a286626c81c2c21db83127 Mon Sep 17 00:00:00 2001
From: Sergei Krivonos <sergeikrivonos@gmail.com>
Date: Sun, 16 Apr 2017 09:11:23 +0300
Subject: [PATCH] moving from boost::regex to std::regex

---
 lib/srchilite/chartranslator.cc             |  8 ++--
 lib/srchilite/chartranslator.h              |  4 +-
 lib/srchilite/doctemplate.cpp               | 28 ++++++------
 lib/srchilite/highlightbuilderexception.cpp |  4 +-
 lib/srchilite/highlightbuilderexception.h   |  8 ++--
 lib/srchilite/highlightstatebuilder.cpp     |  2 +-
 lib/srchilite/langmap.cpp                   |  8 ++--
 lib/srchilite/languageinfer.cpp             | 38 ++++++++--------
 lib/srchilite/lineranges.cpp                | 20 ++++-----
 lib/srchilite/regexhighlightrule.cpp        | 21 ++++-----
 lib/srchilite/regexhighlightrule.h          |  5 ++-
 lib/srchilite/regexpreprocessor.cpp         | 68 ++++++++++++++---------------
 lib/srchilite/regexpreprocessor.h           |  6 +--
 lib/srchilite/regexranges.cpp               | 10 ++---
 lib/srchilite/regexranges.h                 |  8 ++--
 lib/srchilite/regexrulefactory.h            |  2 +-
 lib/srchilite/settings.cpp                  |  8 ++--
 lib/srchilite/srcuntabifier.cpp             | 10 ++---
 lib/srchilite/substfun.cpp                  |  8 ++--
 lib/srchilite/substfun.h                    |  4 +-
 lib/srchilite/textstyle.cpp                 | 12 ++---
 lib/srchilite/textstyle.h                   |  4 +-
 lib/srchilite/wordtokenizer.cpp             |  8 ++--
 lib/tests/stdboosterror.h                   |  2 +-
 lib/tests/test_regexpreprocessor_main.cpp   | 16 +++----
 lib/tests/test_regexranges_main.cpp         |  2 +-
 lib/tests/test_regexrules_main.cpp          | 14 +++---
 m4/ax_boost_regex.m4                        |  4 +-
 28 files changed, 167 insertions(+), 165 deletions(-)

diff --git a/lib/srchilite/chartranslator.cc b/lib/srchilite/chartranslator.cc
index 1449ffc..9dcf4f5 100644
--- a/lib/srchilite/chartranslator.cc
+++ b/lib/srchilite/chartranslator.cc
@@ -59,17 +59,17 @@ const string CharTranslator::doPreformat(const string &text) {
 
     // we finally build the actual regular expression
     if (!reg_exp)
-        reg_exp = new boost::regex(translation_exp);
+        reg_exp = new std::regex(translation_exp);
 
-    boost::match_flag_type flags = boost::match_default | boost::format_all;
+    std::regex_constants::match_flag_type flags = std::regex_constants::match_default | std::regex_constants::format_sed;
     if (!bol)
-        flags |= boost::match_not_bol;
+        flags |= std::regex_constants::match_not_bol;
     // if we're not at the beginning of the line, then we must not match the
     // beginning of the string as the beginning of a line
 
     std::ostringstream preformat_text(std::ios::out | std::ios::binary);
     std::ostream_iterator<char, char> oi(preformat_text);
-    boost::regex_replace(oi, text.begin(), text.end(), *reg_exp,
+    std::regex_replace(oi, text.begin(), text.end(), *reg_exp,
             translation_format, flags);
 
     // keep track of the fact that we begin a new line
diff --git a/lib/srchilite/chartranslator.h b/lib/srchilite/chartranslator.h
index 0d44ee7..99e6b07 100644
--- a/lib/srchilite/chartranslator.h
+++ b/lib/srchilite/chartranslator.h
@@ -23,7 +23,7 @@
 #define NUM_OF_CHARS 256
 
 #include <string>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "preformatter.h"
 
@@ -45,7 +45,7 @@ protected:
     /// the corresponding translated regular expression (for buffering)
     std::string translation_format;
     /// the actual regular expression
-    boost::regex *reg_exp;
+    std::regex *reg_exp;
     /// whether we are at the beginning of a new line
     bool bol;
 
diff --git a/lib/srchilite/doctemplate.cpp b/lib/srchilite/doctemplate.cpp
index a110020..c4e1038 100644
--- a/lib/srchilite/doctemplate.cpp
+++ b/lib/srchilite/doctemplate.cpp
@@ -44,13 +44,13 @@ DocTemplate::output_begin(const string &title, const string &cs, const string &a
     const string &header, const string &footer, const std::string &background,
     const string &input_lang)
 {
-    boost::regex title_exp(TITLE_VAR);
-    boost::regex css_exp(CSS_VAR);
-    boost::regex additional_exp(ADDITIONAL_VAR);
-    boost::regex header_exp(HEADER_VAR);
-    boost::regex footer_exp(FOOTER_VAR);
-    boost::regex background_exp(BACKGROUND_VAR);
-    boost::regex input_lang_exp(INPUT_LANG_VAR);
+    std::regex title_exp(TITLE_VAR);
+    std::regex css_exp(CSS_VAR);
+    std::regex additional_exp(ADDITIONAL_VAR);
+    std::regex header_exp(HEADER_VAR);
+    std::regex footer_exp(FOOTER_VAR);
+    std::regex background_exp(BACKGROUND_VAR);
+    std::regex input_lang_exp(INPUT_LANG_VAR);
 
     string ret = subst(title_exp, begin_repr, title);
     ret = subst(css_exp, ret, cs);
@@ -68,13 +68,13 @@ DocTemplate::output_end(const string &title, const string &cs, const string &add
     const string &header, const string &footer, const std::string &background, 
     const string &input_lang)
 {
-    boost::regex title_exp(TITLE_VAR);
-    boost::regex css_exp(CSS_VAR);
-    boost::regex additional_exp(ADDITIONAL_VAR);
-    boost::regex header_exp(HEADER_VAR);
-    boost::regex footer_exp(FOOTER_VAR);
-    boost::regex background_exp(BACKGROUND_VAR);
-    boost::regex input_lang_exp(INPUT_LANG_VAR);
+    std::regex title_exp(TITLE_VAR);
+    std::regex css_exp(CSS_VAR);
+    std::regex additional_exp(ADDITIONAL_VAR);
+    std::regex header_exp(HEADER_VAR);
+    std::regex footer_exp(FOOTER_VAR);
+    std::regex background_exp(BACKGROUND_VAR);
+    std::regex input_lang_exp(INPUT_LANG_VAR);
 
     string ret = subst(title_exp, end_repr, title);
     ret = subst(css_exp, ret, cs);
diff --git a/lib/srchilite/highlightbuilderexception.cpp b/lib/srchilite/highlightbuilderexception.cpp
index 40a4982..40e0499 100644
--- a/lib/srchilite/highlightbuilderexception.cpp
+++ b/lib/srchilite/highlightbuilderexception.cpp
@@ -19,14 +19,14 @@ namespace srchilite {
 
 HighlightBuilderException::HighlightBuilderException(
         const std::string &_message, const ParserInfo *parserinfo,
-        const boost::regex_error &e) :
+        const std::regex_error &e) :
     message(_message), causedBy(e), filename(parserinfo->filename),
             line(parserinfo->line) {
 }
 
 HighlightBuilderException::HighlightBuilderException(
         const std::string &_message, const std::string &_filename,
-        unsigned int _line, const boost::regex_error &e) :
+        unsigned int _line, const std::regex_error &e) :
     message(_message), causedBy(e), filename(_filename), line(_line) {
 }
 
diff --git a/lib/srchilite/highlightbuilderexception.h b/lib/srchilite/highlightbuilderexception.h
index 40e4d3f..82fd619 100644
--- a/lib/srchilite/highlightbuilderexception.h
+++ b/lib/srchilite/highlightbuilderexception.h
@@ -8,7 +8,7 @@
 #define HIGHLIGHTBUILDEREXCEPTION_H_
 
 #include <ostream>
-#include <boost/regex/pattern_except.hpp>
+#include <regex>
 #include <string>
 
 namespace srchilite {
@@ -20,7 +20,7 @@ struct HighlightBuilderException : public std::exception {
     std::string message;
 
     /// possible exception that caused this one
-    boost::regex_error causedBy;
+    std::regex_error causedBy;
 
     /// filename of the element that caused this exception
     std::string filename;
@@ -30,10 +30,10 @@ struct HighlightBuilderException : public std::exception {
 
     HighlightBuilderException(const std::string &_message,
             const ParserInfo *parserinfo,
-            const boost::regex_error &e = boost::regex_error(boost::regex_constants::error_bad_pattern));
+            const std::regex_error &e = std::regex_error(std::regex_constants::error_badbrace));
     HighlightBuilderException(const std::string &_message,
             const std::string &filename = "", unsigned int line = 0,
-            const boost::regex_error &e = boost::regex_error(boost::regex_constants::error_bad_pattern));
+            const std::regex_error &e = std::regex_error(std::regex_constants::error_badbrace));
     virtual ~HighlightBuilderException() throw();
 
     virtual const char* what ( ) const throw () ;
diff --git a/lib/srchilite/highlightstatebuilder.cpp b/lib/srchilite/highlightstatebuilder.cpp
index 4a52403..93ba8e2 100644
--- a/lib/srchilite/highlightstatebuilder.cpp
+++ b/lib/srchilite/highlightstatebuilder.cpp
@@ -74,7 +74,7 @@ void HighlightStateBuilder::build(LangElems *elems, HighlightStatePtr mainState)
     for (LangElems::const_iterator it = elems->begin(); it != elems->end(); ++it) {
         try {
             build_DB(*it, mainState.get());
-        } catch (boost::regex_error &e) {
+        } catch (std::regex_error &e) {
             // catch all other exceptions
             throw HighlightBuilderException("problem in this expression: "
                     + (*it)->toStringOriginal(), *it, e);
diff --git a/lib/srchilite/langmap.cpp b/lib/srchilite/langmap.cpp
index 7f0d09e..8d8da58 100644
--- a/lib/srchilite/langmap.cpp
+++ b/lib/srchilite/langmap.cpp
@@ -15,7 +15,7 @@
 #endif
 
 #include <iostream>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "langmap.h"
 #include "fileutil.h"
@@ -28,7 +28,7 @@ using namespace std;
 namespace srchilite {
 
 /// the regular expression for the map file syntax
-boost::regex
+std::regex
         assoc_exp(
                 "[[:blank:]]*([^[:blank:]]+)[[:blank:]]*=[[:blank:]]*([^[:blank:]\\r]+)[[:blank:]\\r]*|([[:space:]]+)|([[:space:]]*#.*)");
 
@@ -53,8 +53,8 @@ void LangMap::open() {
 
     while (read_line(in, line)) {
         if (line.size()) {
-            boost::cmatch what;
-            if (!boost::regex_match(line.c_str(), what, assoc_exp))
+            std::cmatch what;
+            if (!std::regex_match(line.c_str(), what, assoc_exp))
                 throw ParserException("wrong specification" + line, filename,
                         lineno);
             else if (!what[3].matched) // not all spaces
diff --git a/lib/srchilite/languageinfer.cpp b/lib/srchilite/languageinfer.cpp
index f077fcc..b3d770c 100644
--- a/lib/srchilite/languageinfer.cpp
+++ b/lib/srchilite/languageinfer.cpp
@@ -18,7 +18,7 @@
 #include "fileutil.h"
 
 #include <boost/algorithm/string.hpp>
-#include <boost/regex.hpp>
+#include <regex>
 #include <vector>
 
 using namespace std;
@@ -68,19 +68,19 @@ const string guessEmacsMode(const string &modeline) {
 const string LanguageInfer::infer(istream &stream) {
     // the regular expression for finding the language specification in a script file
     // this such as #! /bin/bash
-    static boost::regex
+    static std::regex
             langRegEx(
                     "#[[:blank:]]*![[:blank:]]*(?:[\\./]*)(?:[[:alnum:]]+[\\./]+)*([[:alnum:]]+)");
 
     // the regular expression for finding the language specification in a script file
     // this such as #! /usr/bin/env perl
-    static boost::regex
+    static std::regex
             langEnvRegEx(
                     "#[[:blank:]]*![[:blank:]]*(?:[\\./]*)(?:[[:alnum:]]+[\\./]+)*(?:env)[[:blank:]]+([[:alnum:]]+)");
 
     // the regular expression for finding the language specification in a script file
     // according to Emacs convention: # -*- language -*-
-    static boost::regex
+    static std::regex
             langRegExEmacs("-\\*-[[:blank:]]*([[:print:]]+).*-\\*-");
 
     // the Emacs specification has the precedence in order to correctly infer
@@ -91,10 +91,10 @@ const string LanguageInfer::infer(istream &stream) {
 
     // the regular expression for scripts starting with <?...
     // such as xml and php
-    static boost::regex langXMLLikeScripts("<\\?([[:alnum:]]+)");
+    static std::regex langXMLLikeScripts("<\\?([[:alnum:]]+)");
 
     // the regular expression for <!DOCTYPE
-    static boost::regex langDocType("<![Dd][Oo][Cc][Tt][Yy][Pp][Ee]");
+    static std::regex langDocType("<![Dd][Oo][Cc][Tt][Yy][Pp][Ee]");
 
     string firstLine;
     string secondLine;
@@ -104,13 +104,13 @@ const string LanguageInfer::infer(istream &stream) {
     // and the second line
     read_line(&stream, secondLine);
 
-    boost::match_results<std::string::const_iterator> what;
-    boost::match_results<std::string::const_iterator> whatEnv;
-    boost::match_results<std::string::const_iterator> whatEmacs;
+    std::match_results<std::string::const_iterator> what;
+    std::match_results<std::string::const_iterator> whatEnv;
+    std::match_results<std::string::const_iterator> whatEmacs;
 
     // first try the emacs specification
-    boost::regex_search(secondLine, whatEmacs, langRegExEmacs,
-            boost::match_default);
+    std::regex_search(secondLine, whatEmacs, langRegExEmacs,
+            std::regex_constants::match_default);
 
     if (whatEmacs[1].matched) {
         string guess = guessEmacsMode(whatEmacs[1]);
@@ -119,8 +119,8 @@ const string LanguageInfer::infer(istream &stream) {
     }
 
     // try also on the first line
-    boost::regex_search(firstLine, whatEmacs, langRegExEmacs,
-             boost::match_default);
+    std::regex_search(firstLine, whatEmacs, langRegExEmacs,
+             std::regex_constants::match_default);
 
     if (whatEmacs[1].matched) {
         string guess = guessEmacsMode(whatEmacs[1]);
@@ -129,27 +129,27 @@ const string LanguageInfer::infer(istream &stream) {
     }
 
     // try also the env specification
-    boost::regex_search(firstLine, whatEnv, langEnvRegEx, boost::match_default);
+    std::regex_search(firstLine, whatEnv, langEnvRegEx, std::regex_constants::match_default);
 
     if (whatEnv[1].matched)
         return whatEnv[1];
 
     // try the sha-bang specification
-    boost::regex_search(firstLine, what, langRegEx, boost::match_default);
+    std::regex_search(firstLine, what, langRegEx, std::regex_constants::match_default);
 
     if (what[1].matched)
         return what[1];
 
     // the xml like starting scripts
-    boost::regex_search(firstLine, what, langXMLLikeScripts,
-            boost::match_default);
+    std::regex_search(firstLine, what, langXMLLikeScripts,
+            std::regex_constants::match_default);
 
     if (what[1].matched)
         return what[1];
 
     // the doctype case
-    boost::regex_search(firstLine, what, langDocType,
-            boost::match_default);
+    std::regex_search(firstLine, what, langDocType,
+            std::regex_constants::match_default);
 
     if (what[0].matched)
         return "xml";
diff --git a/lib/srchilite/lineranges.cpp b/lib/srchilite/lineranges.cpp
index a80ac9a..8caf1a4 100644
--- a/lib/srchilite/lineranges.cpp
+++ b/lib/srchilite/lineranges.cpp
@@ -13,19 +13,19 @@
 #include "lineranges.h"
 #include <sstream>
 
-#include <boost/regex.hpp>
+#include <regex>
 #include <cstdlib>
 
 namespace srchilite {
 
 /// regular expression for a single line
-static boost::regex singleNumber("\\s*([[:digit:]]+)\\s*");
+static std::regex singleNumber("\\s*([[:digit:]]+)\\s*");
 /// regular expression for an interval
-static boost::regex rangeExp("\\s*([[:digit:]]+)\\s*-\\s*([[:digit:]]+)\\s*");
+static std::regex rangeExp("\\s*([[:digit:]]+)\\s*-\\s*([[:digit:]]+)\\s*");
 /// regular expression for an interval with only the first element
-static boost::regex rangeExp1("\\s*([[:digit:]]+)\\s*-\\s*");
+static std::regex rangeExp1("\\s*([[:digit:]]+)\\s*-\\s*");
 /// regular expression for an interval with only the second element
-static boost::regex rangeExp2("\\s*-\\s*([[:digit:]]+)\\s*");
+static std::regex rangeExp2("\\s*-\\s*([[:digit:]]+)\\s*");
 
 using namespace std;
 
@@ -38,15 +38,15 @@ LineRanges::~LineRanges() {
 }
 
 RangeError LineRanges::addRange(const std::string &range) {
-    boost::smatch match;
-    if (boost::regex_match(range, match, singleNumber)) {
+    std::smatch match;
+    if (std::regex_match(range, match, singleNumber)) {
         lineRangeSet.insert(make_pair(strtol(match[1].str().c_str(), 0, 0), 0));
-    } else if (boost::regex_match(range, match, rangeExp)) {
+    } else if (std::regex_match(range, match, rangeExp)) {
         lineRangeSet.insert(make_pair(strtol(match[1].str().c_str(), 0, 0),
                 strtol(match[2].str().c_str(), 0, 0)));
-    } else if (boost::regex_match(range, match, rangeExp1)) {
+    } else if (std::regex_match(range, match, rangeExp1)) {
         lineRangeSet.insert(make_pair(strtol(match[1].str().c_str(), 0, 0), -1));
-    } else if (boost::regex_match(range, match, rangeExp2)) {
+    } else if (std::regex_match(range, match, rangeExp2)) {
         lineRangeSet.insert(make_pair(-1, strtol(match[1].str().c_str(), 0, 0)));
     } else {
         return INVALID_RANGE_NUMBER;
diff --git a/lib/srchilite/regexhighlightrule.cpp b/lib/srchilite/regexhighlightrule.cpp
index 458e63f..7258f06 100644
--- a/lib/srchilite/regexhighlightrule.cpp
+++ b/lib/srchilite/regexhighlightrule.cpp
@@ -16,16 +16,16 @@
 namespace srchilite {
 
 /// the only spaces regular expression
-static boost::regex onlySpaces("[[:blank:]]*");
+static std::regex onlySpaces("[[:blank:]]*");
 
 RegexHighlightRule::RegexHighlightRule(const std::string &s) :
-    regExp(s) {
+    regExp(s), regExpStr(s) {
 
 }
 
 RegexHighlightRule::RegexHighlightRule(const std::string &name,
         const std::string &s) :
-    HighlightRule(name), regExp(s) {
+    HighlightRule(name), regExp(s), regExpStr(s) {
 
 }
 
@@ -35,23 +35,23 @@ RegexHighlightRule::~RegexHighlightRule() {
 bool RegexHighlightRule::tryToMatch(std::string::const_iterator start,
         std::string::const_iterator end, HighlightToken &token,
         const MatchingParameters &params) {
-    boost::smatch match;
-    boost::match_flag_type flags = boost::match_default;
+    std::smatch match;
+    auto flags = std::regex_constants::match_default;
 
     // whether this rule represents multiple elements
     bool hasMultipleElements = (getElemList().size() > 1);
 
     if (!params.beginningOfLine) {
         // the start of the string must not be interpreted as the beginning of the line
-        flags |= boost::match_not_bol;
+        flags |= std::regex_constants::match_not_bol;
     }
 
-    if (boost::regex_search(start, end, match, regExp, flags)) {
+    if (std::regex_search(start, end, match, regExp, flags)) {
         token.prefix = match.prefix();
         token.suffix = match.suffix();
 
         // check that the prefix is empty or contains only spaces
-        token.prefixOnlySpaces = boost::regex_match(token.prefix, onlySpaces);
+        token.prefixOnlySpaces = std::regex_match(token.prefix, onlySpaces);
 
         if (getHasSubexpressions()) {
             // record all the matched subexpressions
@@ -77,11 +77,11 @@ bool RegexHighlightRule::tryToMatch(std::string::const_iterator start,
 }
 
 const std::string RegexHighlightRule::toString() const {
-    return regExp.str();
+    return regExpStr;
 }
 
 void RegexHighlightRule::replaceReferences(const ReplacementList &rep) {
-    regExp.assign(RegexPreProcessor::replace_references(regExp.str(), rep));
+    regExp.assign(RegexPreProcessor::replace_references(regExpStr, rep));
 }
 
 HighlightRule *RegexHighlightRule::clone() {
@@ -90,6 +90,7 @@ HighlightRule *RegexHighlightRule::clone() {
 
 void RegexHighlightRule::setRegExp(const std::string &s) {
     regExp.assign(s);
+    regExpStr = s;
 }
 
 }
diff --git a/lib/srchilite/regexhighlightrule.h b/lib/srchilite/regexhighlightrule.h
index d39614b..b97328a 100644
--- a/lib/srchilite/regexhighlightrule.h
+++ b/lib/srchilite/regexhighlightrule.h
@@ -9,7 +9,7 @@
 
 #include "highlightrule.h"
 
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace srchilite {
 
@@ -18,7 +18,8 @@ namespace srchilite {
  */
 class RegexHighlightRule : public HighlightRule {
     /// the regular expression for the rule
-    boost::regex regExp;
+    std::regex regExp;
+    std::string regExpStr;
 public:
     /**
      * @param s the string representing the regular expression
diff --git a/lib/srchilite/regexpreprocessor.cpp b/lib/srchilite/regexpreprocessor.cpp
index e9cc577..b1d86ca 100644
--- a/lib/srchilite/regexpreprocessor.cpp
+++ b/lib/srchilite/regexpreprocessor.cpp
@@ -15,7 +15,7 @@
 #endif
 
 #include "regexpreprocessor.h"
-#include <boost/regex.hpp>
+#include <regex>
 #include <sstream>
 #include <ctype.h>
 #include <iostream>
@@ -28,18 +28,18 @@ namespace srchilite {
 // regular expression they try to match is a valid regular expression
 
 /// matches character sets in a regular expression
-const boost::regex char_set_exp("\\[([^\\|]*)\\]");
+const std::regex char_set_exp("\\[([^\\|]*)\\]");
 
 /// substitute a "(" with "(?:" if it's not followed by a ? and not preceeded by \\ char
-const boost::regex from("(\\\\\\()|(\\((?!\\?))");
+const std::regex from("(\\\\\\()|(\\((?!\\?))");
 /// substitute a "(" with "(?:" if it's not followed by a ? and not preceeded by \\ char
 const string into = "(?1\\\\\\()(?2\\(\\?\\:)";
 
 /// found actual marking parenthesis, i.e., not preceeded by \\ and not followed by ?
-const boost::regex paren("(?<!\\\\)\\((?!\\?)");
+const std::regex paren("(?<!\\\\)\\((?!\\?)");
 
 /// regular expression matching a backreference, e.g., \1 or inside a conditional (?(1)...)
-const boost::regex
+const std::regex
         backreference("(\\\\([[:digit:]]))|(\\(\\?\\(([[:digit:]]))");
 
 /// index of the subexpression matching a slashed backreference
@@ -53,10 +53,10 @@ const boost::regex
 
 /** regular expression matching a reference, e.g., @{digit} the @$ must not be preceeded
  by an escape char */
-const boost::regex reference_exp("(?<!\\\\)@\\{([[:digit:]])\\}");
+const std::regex reference_exp("(?<!\\\\)@\\{([[:digit:]])\\}");
 
 /// substitute a special char (i.e., .[{()\*+?|^$)...
-const boost::regex special_char("(\\.|\\[|\\]|\\{|\\}|\\(|\\)|\\\\|\\*|\\+|\\?|\\||\\^|\\$)");
+const std::regex special_char("(\\.|\\[|\\]|\\{|\\}|\\(|\\)|\\\\|\\*|\\+|\\?|\\||\\^|\\$)");
 /// ...with its escaped version
 const string special_char_escape = "(?1\\\\\\1)";
 
@@ -81,8 +81,8 @@ RegexPreProcessor::~RegexPreProcessor() {
 
 const string RegexPreProcessor::preprocess(const string &s) {
     // substitute a "(" with "(?:" if it's not followed by a ? and not preceeded by \\ char
-    return boost::regex_replace(s, from, into, boost::match_default
-            | boost::format_all);
+    return std::regex_replace(s, from, into, std::regex_constants::match_default
+            | std::regex_constants::format_default);
 }
 
 const string _make_nonsensitive(const string &s) {
@@ -98,8 +98,8 @@ const string _make_nonsensitive(const string &s) {
 }
 
 const string RegexPreProcessor::make_nonsensitive(const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), char_set_exp);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), char_set_exp);
+    std::sregex_iterator m2;
 
     if (m1 == m2)
         return _make_nonsensitive(s);
@@ -108,7 +108,7 @@ const string RegexPreProcessor::make_nonsensitive(const string &s) {
     string prefix;
     string suffix;
 
-    for (boost::sregex_iterator it = m1; it != m2; ++it) {
+    for (std::sregex_iterator it = m1; it != m2; ++it) {
         prefix = it->prefix();
         suffix = it->suffix();
 
@@ -127,12 +127,12 @@ const string RegexPreProcessor::make_nonsensitive(const string &s) {
 }
 
 unsigned int RegexPreProcessor::num_of_subexpressions(const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), paren);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), paren);
+    std::sregex_iterator m2;
 
     int counter = 0;
 
-    for (boost::sregex_iterator it = m1; it != m2; ++it) {
+    for (std::sregex_iterator it = m1; it != m2; ++it) {
         ++counter;
     }
 
@@ -141,8 +141,8 @@ unsigned int RegexPreProcessor::num_of_subexpressions(const string &s) {
 
 const subexpressions_strings *RegexPreProcessor::split_marked_subexpressions(
         const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), paren);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), paren);
+    std::sregex_iterator m2;
 
     // we don't need to parse it (we can use the regex) since we assume that
     // the regular expression represented by s is made up of only
@@ -150,7 +150,7 @@ const subexpressions_strings *RegexPreProcessor::split_marked_subexpressions(
 
     subexpressions_strings *split = new subexpressions_strings;
 
-    for (boost::sregex_iterator it = m1; it != m2;) {
+    for (std::sregex_iterator it = m1; it != m2;) {
         string prefix = it->prefix();
         if (prefix.size())
             split->push_back("(" + prefix);
@@ -253,16 +253,16 @@ subexpressions_info RegexPreProcessor::num_of_marked_subexpressions(
 }
 
 bool RegexPreProcessor::contains_backreferences(const std::string &s) {
-    return boost::regex_search(s, backreference);
+    return std::regex_search(s, backreference);
 }
 
 backreference_info RegexPreProcessor::num_of_backreferences(const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), backreference);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), backreference);
+    std::sregex_iterator m2;
 
     backreference_info info(std::make_pair(0, 0));
 
-    for (boost::sregex_iterator it = m1; it != m2; ++it) {
+    for (std::sregex_iterator it = m1; it != m2; ++it) {
         ++(info.first);
         // for converting a string into the number
         stringstream buffer;
@@ -286,12 +286,12 @@ backreference_info RegexPreProcessor::num_of_backreferences(const string &s) {
 }
 
 backreference_info RegexPreProcessor::num_of_references(const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), reference_exp);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), reference_exp);
+    std::sregex_iterator m2;
 
     backreference_info info(std::make_pair(0, 0));
 
-    for (boost::sregex_iterator it = m1; it != m2; ++it) {
+    for (std::sregex_iterator it = m1; it != m2; ++it) {
         ++(info.first);
         // for converting a string into the number
         stringstream buffer;
@@ -313,8 +313,8 @@ backreference_info RegexPreProcessor::num_of_references(const string &s) {
 
 const std::string RegexPreProcessor::replace_backreferences(
         const std::string &original, const backreference_replacements &replace) {
-    boost::sregex_iterator m1(original.begin(), original.end(), backreference);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(original.begin(), original.end(), backreference);
+    std::sregex_iterator m2;
 
     if (m1 == m2) {
         // no backreference in the current string
@@ -323,7 +323,7 @@ const std::string RegexPreProcessor::replace_backreferences(
 
     ostringstream result;
 
-    for (boost::sregex_iterator it = m1; it != m2;) {
+    for (std::sregex_iterator it = m1; it != m2;) {
         string prefix = it->prefix();
         if (prefix.size())
             result << prefix;
@@ -372,8 +372,8 @@ const std::string RegexPreProcessor::replace_backreferences(
 
 const string RegexPreProcessor::replace_references(
         const std::string &original, const backreference_replacements &replace) {
-    boost::sregex_iterator m1(original.begin(), original.end(), reference_exp);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(original.begin(), original.end(), reference_exp);
+    std::sregex_iterator m2;
 
     if (m1 == m2) {
         // no backreference in the current string
@@ -382,7 +382,7 @@ const string RegexPreProcessor::replace_references(
 
     ostringstream result;
 
-    for (boost::sregex_iterator it = m1; it != m2;) {
+    for (std::sregex_iterator it = m1; it != m2;) {
         string prefix = it->prefix();
         if (prefix.size())
             result << prefix;
@@ -400,9 +400,9 @@ const string RegexPreProcessor::replace_references(
         // string, after escaping non-alphanumerical characters
         // this is necessary since this string will be used to create a regular
         // expression
-        result << boost::regex_replace(replace[backreference_num-1],
-                special_char, special_char_escape, boost::match_default
-                | boost::format_all);
+        result << std::regex_replace(replace[backreference_num-1],
+                special_char, special_char_escape, std::regex_constants::match_default
+                | std::regex_constants::format_default);
 
         string suffix = it->suffix();
         if (++it == m2)
diff --git a/lib/srchilite/regexpreprocessor.h b/lib/srchilite/regexpreprocessor.h
index 4eda315..beb14d0 100644
--- a/lib/srchilite/regexpreprocessor.h
+++ b/lib/srchilite/regexpreprocessor.h
@@ -16,7 +16,7 @@
 #include <list>
 #include <utility>
 #include <vector>
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace srchilite {
 
@@ -58,9 +58,9 @@ typedef std::pair<int, int> backreference_info;
 typedef std::vector<std::string> backreference_replacements;
 
 /**
- * The result of boost::regex_search
+ * The result of std::regex_search
  */
-typedef boost::match_results<std::string::const_iterator> regex_match_results;
+typedef std::match_results<std::string::const_iterator> regex_match_results;
 
 /**
  preprocess a regular expression, e.g., transform "()" into "(?:)"
diff --git a/lib/srchilite/regexranges.cpp b/lib/srchilite/regexranges.cpp
index 90e064b..aa3d01b 100644
--- a/lib/srchilite/regexranges.cpp
+++ b/lib/srchilite/regexranges.cpp
@@ -25,18 +25,18 @@ RegexRanges::~RegexRanges() {
 
 bool RegexRanges::addRegexRange(const std::string &s) {
     try {
-        ranges.push_back(boost::regex(s));
-    } catch (boost::regex_error &e) {
+        ranges.push_back(std::regex(s));
+    } catch (std::regex_error &e) {
         return false;
     }
 
     return true;
 }
 
-const boost::regex *RegexRanges::matches(const std::string &line) {
+const std::regex *RegexRanges::matches(const std::string &line) {
     for (RegexRangesType::const_iterator it = ranges.begin(); it
             != ranges.end(); ++it) {
-        if (boost::regex_search(line, *it)) {
+        if (std::regex_search(line, *it)) {
             return &(*it);
         }
     }
@@ -56,7 +56,7 @@ bool RegexRanges::isInRange(const std::string &line) {
     } else {
         // we're already inside a range, and to find the end of it
         // we must match the current regex
-        if (boost::regex_search(line, *currentRegex)) {
+        if (std::regex_search(line, *currentRegex)) {
             // ok we found the end of the range
             // so first, reset current regular expression
             currentRegex = 0;
diff --git a/lib/srchilite/regexranges.h b/lib/srchilite/regexranges.h
index f658308..fe6402c 100644
--- a/lib/srchilite/regexranges.h
+++ b/lib/srchilite/regexranges.h
@@ -11,7 +11,7 @@
 
 #include <string>
 #include <list>
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace srchilite {
 
@@ -24,7 +24,7 @@ public:
     RegexRanges();
     ~RegexRanges();
 
-    typedef std::list<boost::regex> RegexRangesType;
+    typedef std::list<std::regex> RegexRangesType;
 
     /**
      * Adds a regular expression range, specified by the passed string.
@@ -48,7 +48,7 @@ public:
      * @param line
      * @return the matched regular expression or 0 if none was found
      */
-    const boost::regex *matches(const std::string &line);
+    const std::regex *matches(const std::string &line);
 
     /**
      * @param line the line to inspect
@@ -76,7 +76,7 @@ private:
      * The end of the range will be found when we match again the previously
      * matched expression.
      */
-    const boost::regex *currentRegex;
+    const std::regex *currentRegex;
 };
 
 }
diff --git a/lib/srchilite/regexrulefactory.h b/lib/srchilite/regexrulefactory.h
index 7f18abc..6e3238c 100644
--- a/lib/srchilite/regexrulefactory.h
+++ b/lib/srchilite/regexrulefactory.h
@@ -13,7 +13,7 @@ namespace srchilite {
 
 /**
  * Implementation of the abstract factory, creating highlighting rules
- * based on boost::regex regular expressions.
+ * based on std::regex regular expressions.
  */
 class RegexRuleFactory : public HighlightRuleFactory {
 public:
diff --git a/lib/srchilite/settings.cpp b/lib/srchilite/settings.cpp
index b3eaa73..5ae6aaa 100644
--- a/lib/srchilite/settings.cpp
+++ b/lib/srchilite/settings.cpp
@@ -27,7 +27,7 @@
 #include <cstdlib>
 #include <fstream>
 #include <iostream>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "fileutil.h"
 #include "verbosity.h"
@@ -47,7 +47,7 @@ namespace srchilite {
 string globalDataDir = "";
 
 /// the regular expression for the conf file syntax
-boost::regex
+std::regex
         datadir_exp(
                 "[[:blank:]]*(datadir)[[:blank:]]*=[[:blank:]]*\"([^[:blank:]\\r]+)\"[[:blank:]\\r]*|([[:space:]]+)|([[:space:]]*#.*)");
 
@@ -112,8 +112,8 @@ bool Settings::readDataDir() {
     if (!i.fail()) {
         while (read_line(&i, line)) {
             if (line.size()) {
-                boost::cmatch what;
-                if (boost::regex_match(line.c_str(), what, datadir_exp)
+                std::cmatch what;
+                if (std::regex_match(line.c_str(), what, datadir_exp)
                         && what[2].matched) {// not all spaces, nor comments
                     dataDir = what[2];
                     return true;
diff --git a/lib/srchilite/srcuntabifier.cpp b/lib/srchilite/srcuntabifier.cpp
index fcc4c07..50c6868 100644
--- a/lib/srchilite/srcuntabifier.cpp
+++ b/lib/srchilite/srcuntabifier.cpp
@@ -16,15 +16,15 @@
 
 #include "srcuntabifier.h"
 #include <sstream>
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace srchilite {
 
-const boost::regex tabexp("[\\t]");
+const std::regex tabexp("[\\t]");
 
 const string Untabifier::doPreformat(const string &s) {
-    boost::sregex_iterator m1(s.begin(), s.end(), tabexp);
-    boost::sregex_iterator m2;
+    std::sregex_iterator m1(s.begin(), s.end(), tabexp);
+    std::sregex_iterator m2;
 
     if (m1 == m2) {
         if (s[0] == '\n')
@@ -39,7 +39,7 @@ const string Untabifier::doPreformat(const string &s) {
     string prefix;
     string suffix;
 
-    for (boost::sregex_iterator it = m1; it != m2; ++it) {
+    for (std::sregex_iterator it = m1; it != m2; ++it) {
         prefix = it->prefix();
         suffix = it->suffix();
         if (prefix.size()) {
diff --git a/lib/srchilite/substfun.cpp b/lib/srchilite/substfun.cpp
index 08bc6ef..34d5bfc 100644
--- a/lib/srchilite/substfun.cpp
+++ b/lib/srchilite/substfun.cpp
@@ -18,19 +18,19 @@ using namespace std;
 namespace srchilite {
 
 string
-subst(const boost::regex &e, const string &s, const string &sub)
+subst(const std::regex &e, const string &s, const string &sub)
 {
     string ret;
 
-    boost::sregex_iterator i1(s.begin(), s.end(), e);
-    boost::sregex_iterator i2;
+    std::sregex_iterator i1(s.begin(), s.end(), e);
+    std::sregex_iterator i2;
     string suffix;
 
     if (i1 == i2)
         return s;
     // the exp is not in the string so we do not alter it.
 
-    for (boost::sregex_iterator it = i1; it != i2; ++it) {
+    for (std::sregex_iterator it = i1; it != i2; ++it) {
         string prefix = it->prefix();
         if (prefix.size())
             ret += prefix;
diff --git a/lib/srchilite/substfun.h b/lib/srchilite/substfun.h
index bf1f6eb..3086afb 100644
--- a/lib/srchilite/substfun.h
+++ b/lib/srchilite/substfun.h
@@ -10,12 +10,12 @@
 #ifndef _SUBSTFUN_H_
 #define _SUBSTFUN_H_
 
-#include <boost/regex.hpp>
+#include <regex>
 #include <string>
 
 namespace srchilite {
 
-std::string subst(const boost::regex &e, const std::string &s, const std::string &sub);
+std::string subst(const std::regex &e, const std::string &s, const std::string &sub);
 
 }
 
diff --git a/lib/srchilite/textstyle.cpp b/lib/srchilite/textstyle.cpp
index 8b5ee53..7b88378 100644
--- a/lib/srchilite/textstyle.cpp
+++ b/lib/srchilite/textstyle.cpp
@@ -37,7 +37,7 @@ TextStyle::TextStyle(const string &s,const char **vars) : repr((s.size() ? s : T
 
   exp_buff << ")";
 
-  var_exp = boost::regex(exp_buff.str());
+  var_exp = std::regex(exp_buff.str());
 }
 
 TextStyle::~TextStyle()
@@ -70,15 +70,15 @@ TextStyle::build_vectors()
   parts.clear();
   substitutions.clear();
 
-  boost::sregex_iterator i1(repr.begin(), repr.end(), var_exp);
-  boost::sregex_iterator i2;
+  std::sregex_iterator i1(repr.begin(), repr.end(), var_exp);
+  std::sregex_iterator i2;
   string suffix;
 
   if (i1 == i2)
     return ;
 
   int index = -1;
-  for (boost::sregex_iterator it = i1; it != i2; ++it) {
+  for (std::sregex_iterator it = i1; it != i2; ++it) {
     string prefix = it->prefix();
     if (prefix.size()) {
       parts.push_back(prefix);
@@ -177,8 +177,8 @@ TextStyle::update(const TextStyle &inner)
 bool
 TextStyle::containsStyleVar() const
 {
-    boost::regex style_exp(STYLE_VAR);
-    return boost::regex_search(repr, style_exp);
+    std::regex style_exp(STYLE_VAR);
+    return std::regex_search(repr, style_exp);
 }
 
 bool
diff --git a/lib/srchilite/textstyle.h b/lib/srchilite/textstyle.h
index cd85d4a..ef9db02 100644
--- a/lib/srchilite/textstyle.h
+++ b/lib/srchilite/textstyle.h
@@ -16,7 +16,7 @@
 #include <string>
 #include <vector>
 #include <map>
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace srchilite {
 
@@ -40,7 +40,7 @@ private:
     typedef std::map<std::string, IndexVector> SubstitutionIndexes;
 
     /// the regular expression to find variable occurrences
-    boost::regex var_exp;
+    std::regex var_exp;
 
     std::string repr;
 
diff --git a/lib/srchilite/wordtokenizer.cpp b/lib/srchilite/wordtokenizer.cpp
index 2bf1507..c7ef402 100644
--- a/lib/srchilite/wordtokenizer.cpp
+++ b/lib/srchilite/wordtokenizer.cpp
@@ -8,7 +8,7 @@
 #include "config.h"
 #endif
 
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "wordtokenizer.h"
 
@@ -17,7 +17,7 @@ namespace srchilite {
 /**
  * the regular expression for detecting spaces and words
  */
-static boost::regex string_or_space_regex("([^[:blank:]]+)|([[:blank:]]+)");
+static std::regex string_or_space_regex("([^[:blank:]]+)|([[:blank:]]+)");
 
 using namespace std;
 
@@ -26,8 +26,8 @@ using namespace std;
 
 void WordTokenizer::tokenize(const std::string &s,
         WordTokenizerResults &results) {
-    boost::sregex_iterator i(s.begin(), s.end(), string_or_space_regex);
-    boost::sregex_iterator j;
+    std::sregex_iterator i(s.begin(), s.end(), string_or_space_regex);
+    std::sregex_iterator j;
     while (i != j) {
         if ((*i)[SPACE].matched) {
             results.push_back(make_pair(string((*i)[SPACE].first, (*i)[SPACE].second), ""));
diff --git a/lib/tests/stdboosterror.h b/lib/tests/stdboosterror.h
index 568545b..a1ba162 100644
--- a/lib/tests/stdboosterror.h
+++ b/lib/tests/stdboosterror.h
@@ -4,7 +4,7 @@
 #include <boost/regex/pattern_except.hpp>
 
 static boost::regex_error
-        std_boost_exception(boost::regex_error(boost::regex_constants::error_bad_pattern));
+        std_boost_exception(boost::regex_constants::error_bad_pattern);
 
 /**
  * returns the string representing a standard exception (which
diff --git a/lib/tests/test_regexpreprocessor_main.cpp b/lib/tests/test_regexpreprocessor_main.cpp
index 48748e8..4c32ecf 100644
--- a/lib/tests/test_regexpreprocessor_main.cpp
+++ b/lib/tests/test_regexpreprocessor_main.cpp
@@ -29,7 +29,7 @@
 
 #include <iostream>
 #include <cstdlib>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "asserttestexit.h"
 #include "srchilite/regexpreprocessor.h"
@@ -301,13 +301,13 @@ int main() {
             replace, "Here are special chars: \\| \\$ \\{ =");
 
     // now test substitutions using match results
-    boost::regex test_regex("--\\[(=*)\\[");
+    std::regex test_regex("--\\[(=*)\\[");
     string to_match = "--[[";
     string to_substitute = "]]"; // between the ] ]
     regex_match_results what;
 
     assertEquals(true,
-            boost::regex_search(to_match, what, test_regex));
+            std::regex_search(to_match, what, test_regex));
     // no substitution must take place
     testReferenceReplace(to_substitute, what, "]]");
 
@@ -318,16 +318,16 @@ int main() {
     to_match = "--[=[";
 
     assertEquals(true,
-            boost::regex_search(to_match, what, test_regex));
+            std::regex_search(to_match, what, test_regex));
     testReferenceReplace(to_substitute, what, "]=]");
 
-    test_regex = boost::regex("--\\[(=*)\\[(-*)\\[");
+    test_regex = std::regex("--\\[(=*)\\[(-*)\\[");
     what = regex_match_results();
     to_substitute = "]@{1}]@{2}]";
     to_match = "--[=[-[";
 
     assertEquals(true,
-            boost::regex_search(to_match, what, test_regex));
+            std::regex_search(to_match, what, test_regex));
     testReferenceReplace(to_substitute, what, "]=]-]");
 
     what = regex_match_results();
@@ -335,7 +335,7 @@ int main() {
 
     to_substitute = "](?(@{1})@{1}|@{2})]@{2}]";
     assertEquals(true,
-            boost::regex_search(to_match, what, test_regex));
+            std::regex_search(to_match, what, test_regex));
     testReferenceReplace(to_substitute, what, "](?(=)=|-)]-]");
 
     what = regex_match_results();
@@ -343,7 +343,7 @@ int main() {
     to_match = "--[=[[";
 
     assertEquals(true,
-            boost::regex_search(to_match, what, test_regex));
+            std::regex_search(to_match, what, test_regex));
     testReferenceReplace(to_substitute, what, "](?(=)=|)]]");
 
     // check StringDef for backreferences
diff --git a/lib/tests/test_regexranges_main.cpp b/lib/tests/test_regexranges_main.cpp
index 567d792..93699a4 100644
--- a/lib/tests/test_regexranges_main.cpp
+++ b/lib/tests/test_regexranges_main.cpp
@@ -24,7 +24,7 @@ void check_range_regex(const string &s, bool expectedTrue = true) {
 
 void check_match(const string &line, const string &expected = "") {
     cout << "searching inside " << line;
-    const boost::regex *matched = 0;
+    const std::regex *matched = 0;
     if (expected != "") {
         matched = ranges.matches(line);
         assertTrue(matched != 0);
diff --git a/lib/tests/test_regexrules_main.cpp b/lib/tests/test_regexrules_main.cpp
index 21ef070..480bc61 100644
--- a/lib/tests/test_regexrules_main.cpp
+++ b/lib/tests/test_regexrules_main.cpp
@@ -5,7 +5,7 @@
 #endif
 
 #include <iostream>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "asserttestexit.h"
 #include "srchilite/regexrulefactory.h"
@@ -123,13 +123,13 @@ int main() {
     cout << "*** test_regexrules" << endl;
 
     // first of all check the only spaces regular expression
-    boost::regex onlySpaces("[[:blank:]]*");
+    std::regex onlySpaces("[[:blank:]]*");
 
-    assertTrue(boost::regex_match(" \t \t ", onlySpaces));
-    assertTrue(boost::regex_match("", onlySpaces));
-    assertFalse(boost::regex_match(" a\t \t ", onlySpaces));
-    assertFalse(boost::regex_match(" a ", onlySpaces));
-    assertFalse(boost::regex_match("foo", onlySpaces));
+    assertTrue(std::regex_match(" \t \t ", onlySpaces));
+    assertTrue(std::regex_match("", onlySpaces));
+    assertFalse(std::regex_match(" a\t \t ", onlySpaces));
+    assertFalse(std::regex_match(" a ", onlySpaces));
+    assertFalse(std::regex_match("foo", onlySpaces));
 
     RegexRuleFactory factory;
 
diff --git a/m4/ax_boost_regex.m4 b/m4/ax_boost_regex.m4
index 665b006..7252ec6 100644
--- a/m4/ax_boost_regex.m4
+++ b/m4/ax_boost_regex.m4
@@ -65,9 +65,9 @@ AC_DEFUN([AX_BOOST_REGEX],
         AC_CACHE_CHECK(whether the Boost::Regex library is available,
 					   ax_cv_boost_regex,
         [AC_LANG_PUSH([C++])
-			 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
+			 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <regex>
 												]],
-                                   [[boost::regex r(); return 0;]])],
+                                   [[std::regex r(); return 0;]])],
                    ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
          AC_LANG_POP([C++])
 		])
-- 
2.11.0 (Apple Git-81)

