net+util: remove dependency on Boost.Regex

Use std::regex instead.

Change-Id: I6c53edf177b7861d47a1f256aa975e4100e00d45
diff --git a/src/common-pch.hpp b/src/common-pch.hpp
index 12be185..b03e490 100644
--- a/src/common-pch.hpp
+++ b/src/common-pch.hpp
@@ -47,6 +47,5 @@
 #include <boost/multi_index_container.hpp>
 #include <boost/range/adaptors.hpp>
 #include <boost/range/algorithm/copy.hpp>
-#include <boost/regex.hpp>
 
 #endif // NDN_COMMON_PCH_HPP
diff --git a/src/net/face-uri.cpp b/src/net/face-uri.cpp
index 97fe0f7..ceed453 100644
--- a/src/net/face-uri.cpp
+++ b/src/net/face-uri.cpp
@@ -35,7 +35,8 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/mpl/vector.hpp>
 #include <boost/mpl/for_each.hpp>
-#include <boost/regex.hpp>
+
+#include <regex>
 #include <set>
 #include <sstream>
 
@@ -69,43 +70,43 @@
   m_path.clear();
   m_isV6 = false;
 
-  static const boost::regex protocolExp("(\\w+\\d?(\\+\\w+)?)://([^/]*)(\\/[^?]*)?");
-  boost::smatch protocolMatch;
-  if (!boost::regex_match(uri, protocolMatch, protocolExp)) {
+  static const std::regex protocolExp("(\\w+\\d?(\\+\\w+)?)://([^/]*)(\\/[^?]*)?");
+  std::smatch protocolMatch;
+  if (!std::regex_match(uri, protocolMatch, protocolExp)) {
     return false;
   }
   m_scheme = protocolMatch[1];
-  const std::string& authority = protocolMatch[3];
+  std::string authority = protocolMatch[3];
   m_path = protocolMatch[4];
 
   // pattern for IPv6 link local address enclosed in [ ], with optional port number
-  static const boost::regex v6LinkLocalExp("^\\[([a-fA-F0-9:]+)%([^\\s/:]+)\\](?:\\:(\\d+))?$");
+  static const std::regex v6LinkLocalExp("^\\[([a-fA-F0-9:]+)%([^\\s/:]+)\\](?:\\:(\\d+))?$");
   // pattern for IPv6 address enclosed in [ ], with optional port number
-  static const boost::regex v6Exp("^\\[([a-fA-F0-9:]+)\\](?:\\:(\\d+))?$");
+  static const std::regex v6Exp("^\\[([a-fA-F0-9:]+)\\](?:\\:(\\d+))?$");
   // pattern for Ethernet address in standard hex-digits-and-colons notation
-  static const boost::regex etherExp("^\\[((?:[a-fA-F0-9]{1,2}\\:){5}(?:[a-fA-F0-9]{1,2}))\\]$");
+  static const std::regex etherExp("^\\[((?:[a-fA-F0-9]{1,2}\\:){5}(?:[a-fA-F0-9]{1,2}))\\]$");
   // pattern for IPv4-mapped IPv6 address, with optional port number
-  static const boost::regex v4MappedV6Exp("^\\[::ffff:(\\d+(?:\\.\\d+){3})\\](?:\\:(\\d+))?$");
+  static const std::regex v4MappedV6Exp("^\\[::ffff:(\\d+(?:\\.\\d+){3})\\](?:\\:(\\d+))?$");
   // pattern for IPv4/hostname/fd/ifname, with optional port number
-  static const boost::regex v4HostExp("^([^:]+)(?:\\:(\\d+))?$");
+  static const std::regex v4HostExp("^([^:]+)(?:\\:(\\d+))?$");
 
   if (authority.empty()) {
     // UNIX, internal
   }
   else {
-    boost::smatch match;
-    if (boost::regex_match(authority, match, v6LinkLocalExp)) {
+    std::smatch match;
+    if (std::regex_match(authority, match, v6LinkLocalExp)) {
       m_isV6 = true;
-      m_host = match[1] + "%" + match[2];
+      m_host = match[1].str() + "%" + match[2].str();
       m_port = match[3];
       return true;
     }
 
-    m_isV6 = boost::regex_match(authority, match, v6Exp);
+    m_isV6 = std::regex_match(authority, match, v6Exp);
     if (m_isV6 ||
-        boost::regex_match(authority, match, etherExp) ||
-        boost::regex_match(authority, match, v4MappedV6Exp) ||
-        boost::regex_match(authority, match, v4HostExp)) {
+        std::regex_match(authority, match, etherExp) ||
+        std::regex_match(authority, match, v4MappedV6Exp) ||
+        std::regex_match(authority, match, v4HostExp)) {
       m_host = match[1];
       m_port = match[2];
     }
@@ -269,7 +270,7 @@
     }
 
     boost::system::error_code ec;
-    auto addr = ip::addressFromString(unescapeHost(faceUri.getHost()), ec);
+    auto addr = boost::asio::ip::address::from_string(unescapeHost(faceUri.getHost()), ec);
     if (ec) {
       return false;
     }
@@ -322,7 +323,7 @@
     // make a copy because caller may modify faceUri
     auto uri = make_shared<FaceUri>(faceUri);
     boost::system::error_code ec;
-    auto ipAddress = ip::addressFromString(unescapeHost(faceUri.getHost()), ec);
+    auto ipAddress = boost::asio::ip::address::from_string(unescapeHost(faceUri.getHost()), ec);
     if (!ec) {
       // No need to resolve IP address if host is already an IP
       if ((faceUri.getScheme() == m_v4Scheme && !ipAddress.is_v4()) ||
diff --git a/src/util/regex/regex-component-matcher.cpp b/src/util/regex/regex-component-matcher.cpp
index aca35c1..2c6da84 100644
--- a/src/util/regex/regex-component-matcher.cpp
+++ b/src/util/regex/regex-component-matcher.cpp
@@ -38,7 +38,7 @@
 void
 RegexComponentMatcher::compile()
 {
-  m_componentRegex = boost::regex(m_expr);
+  m_componentRegex.assign(m_expr);
 
   m_pseudoMatchers.clear();
   m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
@@ -62,9 +62,9 @@
   if (!m_isExactMatch)
     BOOST_THROW_EXCEPTION(Error("Non-exact component search is not supported yet"));
 
-  boost::smatch subResult;
+  std::smatch subResult;
   std::string targetStr = name.get(offset).toUri();
-  if (boost::regex_match(targetStr, subResult, m_componentRegex)) {
+  if (std::regex_match(targetStr, subResult, m_componentRegex)) {
     for (size_t i = 1; i <= m_componentRegex.mark_count(); i++) {
       m_pseudoMatchers[i]->resetMatchResult();
       m_pseudoMatchers[i]->setMatchResult(subResult[i]);
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 4c5ecf0..f00b183 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -26,7 +26,7 @@
 
 #include "regex-matcher.hpp"
 
-#include <boost/regex.hpp>
+#include <regex>
 
 namespace ndn {
 
@@ -54,7 +54,7 @@
 
 private:
   bool m_isExactMatch;
-  boost::regex m_componentRegex;
+  std::regex m_componentRegex;
   std::vector<shared_ptr<RegexPseudoMatcher>> m_pseudoMatchers;
 };
 
diff --git a/src/util/regex/regex-repeat-matcher.cpp b/src/util/regex/regex-repeat-matcher.cpp
index 17986bf..0fdc543 100644
--- a/src/util/regex/regex-repeat-matcher.cpp
+++ b/src/util/regex/regex-repeat-matcher.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -25,8 +25,8 @@
 #include "regex-backref-matcher.hpp"
 #include "regex-component-set-matcher.hpp"
 
-#include <boost/regex.hpp>
 #include <cstdlib>
+#include <regex>
 
 namespace ndn {
 
@@ -91,32 +91,30 @@
     size_t min = 0;
     size_t max = 0;
 
-    if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,[0-9]+\\}"))) {
+    if (std::regex_match(repeatStruct, std::regex("\\{[0-9]+,[0-9]+\\}"))) {
       size_t separator = repeatStruct.find_first_of(',', 0);
       min = std::atoi(repeatStruct.substr(1, separator - 1).data());
       max = std::atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).data());
     }
-    else if (boost::regex_match(repeatStruct, boost::regex("\\{,[0-9]+\\}"))) {
+    else if (std::regex_match(repeatStruct, std::regex("\\{,[0-9]+\\}"))) {
       size_t separator = repeatStruct.find_first_of(',', 0);
       min = 0;
       max = std::atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).data());
     }
-    else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,\\}"))) {
+    else if (std::regex_match(repeatStruct, std::regex("\\{[0-9]+,\\}"))) {
       size_t separator = repeatStruct.find_first_of(',', 0);
       min = std::atoi(repeatStruct.substr(1, separator).data());
       max = MAX_REPETITIONS;
     }
-    else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+\\}"))) {
+    else if (std::regex_match(repeatStruct, std::regex("\\{[0-9]+\\}"))) {
       min = std::atoi(repeatStruct.substr(1, rsSize - 1).data());
       max = min;
     }
     else
-      BOOST_THROW_EXCEPTION(Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
-                                  + " Unrecognized format " + m_expr));
+      BOOST_THROW_EXCEPTION(Error("RegexRepeatMatcher::parseRepetition(): Unrecognized format " + m_expr));
 
     if (min > MAX_REPETITIONS || max > MAX_REPETITIONS || min > max)
-      BOOST_THROW_EXCEPTION(Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
-                                  + " Wrong number " + m_expr));
+      BOOST_THROW_EXCEPTION(Error("RegexRepeatMatcher::parseRepetition(): Wrong number " + m_expr));
 
     m_repeatMin = min;
     m_repeatMax = max;
diff --git a/wscript b/wscript
index ee3f835..f21dc15 100644
--- a/wscript
+++ b/wscript
@@ -98,8 +98,7 @@
     conf.check_openssl(mandatory=True, atleast_version=0x1000200f) # 1.0.2
 
     USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
-                       'regex', 'program_options', 'chrono', 'thread',
-                       'log', 'log_setup']
+                       'program_options', 'chrono', 'thread', 'log', 'log_setup']
 
     if conf.env['WITH_TESTS']:
         USED_BOOST_LIBS += ['unit_test_framework']