diff --git a/src/util/regex/regex-backref-manager.cpp b/src/util/regex/regex-backref-manager.cpp
new file mode 100644
index 0000000..23c4a0a
--- /dev/null
+++ b/src/util/regex/regex-backref-manager.cpp
@@ -0,0 +1,44 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-backref-manager.hpp"
+
+namespace ndn {
+
+size_t
+RegexBackrefManager::pushRef(const shared_ptr<RegexMatcher>& matcher)
+{
+  auto last = m_backrefs.size();
+  m_backrefs.emplace_back(matcher);
+  return last;
+}
+
+shared_ptr<RegexMatcher>
+RegexBackrefManager::getBackref(size_t i) const
+{
+  auto backref = m_backrefs[i].lock();
+  BOOST_ASSERT(backref != nullptr);
+  return backref;
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-backref-manager.hpp b/src/util/regex/regex-backref-manager.hpp
index 4e112d7..1a6d14e 100644
--- a/src/util/regex/regex-backref-manager.hpp
+++ b/src/util/regex/regex-backref-manager.hpp
@@ -57,22 +57,6 @@
   std::vector<weak_ptr<RegexMatcher>> m_backrefs;
 };
 
-inline size_t
-RegexBackrefManager::pushRef(const shared_ptr<RegexMatcher>& matcher)
-{
-  auto last = m_backrefs.size();
-  m_backrefs.emplace_back(matcher);
-  return last;
-}
-
-inline shared_ptr<RegexMatcher>
-RegexBackrefManager::getBackref(size_t i) const
-{
-  auto backref = m_backrefs[i].lock();
-  BOOST_ASSERT(backref != nullptr);
-  return backref;
-}
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MANAGER_HPP
diff --git a/src/util/regex/regex-backref-matcher.cpp b/src/util/regex/regex-backref-matcher.cpp
new file mode 100644
index 0000000..5895b8b
--- /dev/null
+++ b/src/util/regex/regex-backref-matcher.cpp
@@ -0,0 +1,50 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-backref-matcher.hpp"
+#include "regex-pattern-list-matcher.hpp"
+
+namespace ndn {
+
+RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr,
+                                         shared_ptr<RegexBackrefManager> backrefManager)
+  : RegexMatcher(expr, EXPR_BACKREF, std::move(backrefManager))
+{
+}
+
+void
+RegexBackrefMatcher::compile()
+{
+  if (m_expr.size() < 2)
+    BOOST_THROW_EXCEPTION(Error("Unrecognized format: " + m_expr));
+
+  size_t lastIndex = m_expr.size() - 1;
+  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]) {
+    m_matchers.push_back(make_shared<RegexPatternListMatcher>(m_expr.substr(1, lastIndex - 1),
+                                                              m_backrefManager));
+  }
+  else
+    BOOST_THROW_EXCEPTION(Error("Unrecognized format: " + m_expr));
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-backref-matcher.hpp b/src/util/regex/regex-backref-matcher.hpp
index 947abc7..565331b 100644
--- a/src/util/regex/regex-backref-matcher.hpp
+++ b/src/util/regex/regex-backref-matcher.hpp
@@ -46,32 +46,4 @@
 
 } // namespace ndn
 
-#include "regex-pattern-list-matcher.hpp"
-
-namespace ndn {
-
-inline
-RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr,
-                                         shared_ptr<RegexBackrefManager> backrefManager)
-  : RegexMatcher(expr, EXPR_BACKREF, std::move(backrefManager))
-{
-}
-
-inline void
-RegexBackrefMatcher::compile()
-{
-  if (m_expr.size() < 2)
-    BOOST_THROW_EXCEPTION(Error("Unrecognized format: " + m_expr));
-
-  size_t lastIndex = m_expr.size() - 1;
-  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]) {
-    m_matchers.push_back(make_shared<RegexPatternListMatcher>(m_expr.substr(1, lastIndex - 1),
-                                                              m_backrefManager));
-  }
-  else
-    BOOST_THROW_EXCEPTION(Error("Unrecognized format: " + m_expr));
-}
-
-} // namespace ndn
-
 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
diff --git a/src/util/regex/regex-component-matcher.cpp b/src/util/regex/regex-component-matcher.cpp
new file mode 100644
index 0000000..8d1e824
--- /dev/null
+++ b/src/util/regex/regex-component-matcher.cpp
@@ -0,0 +1,92 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-component-matcher.hpp"
+#include "regex-pseudo-matcher.hpp"
+
+namespace ndn {
+
+// Re: http://www.boost.org/users/history/version_1_56_0.html
+//
+//   Breaking change: corrected behavior of basic_regex<>::mark_count() to match existing
+//   documentation, basic_regex<>::subexpression(n) changed to match, see
+//   https://svn.boost.org/trac/boost/ticket/9227
+//
+static constexpr size_t BOOST_REGEXP_MARK_COUNT_CORRECTION =
+#if BOOST_VERSION < 105600
+    1;
+#else
+    0;
+#endif
+
+RegexComponentMatcher::RegexComponentMatcher(const std::string& expr,
+                                             shared_ptr<RegexBackrefManager> backrefManager,
+                                             bool isExactMatch)
+  : RegexMatcher(expr, EXPR_COMPONENT, std::move(backrefManager))
+  , m_isExactMatch(isExactMatch)
+{
+  compile();
+}
+
+void
+RegexComponentMatcher::compile()
+{
+  m_componentRegex = boost::regex(m_expr);
+
+  m_pseudoMatchers.clear();
+  m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
+
+  for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
+    m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
+    m_backrefManager->pushRef(m_pseudoMatchers.back());
+  }
+}
+
+bool
+RegexComponentMatcher::match(const Name& name, size_t offset, size_t len)
+{
+  m_matchResult.clear();
+
+  if (m_expr.empty()) {
+    m_matchResult.push_back(name.get(offset));
+    return true;
+  }
+
+  if (!m_isExactMatch)
+    BOOST_THROW_EXCEPTION(Error("Non-exact component search is not supported yet"));
+
+  boost::smatch subResult;
+  std::string targetStr = name.get(offset).toUri();
+  if (boost::regex_match(targetStr, subResult, m_componentRegex)) {
+    for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
+      m_pseudoMatchers[i]->resetMatchResult();
+      m_pseudoMatchers[i]->setMatchResult(subResult[i]);
+    }
+    m_matchResult.push_back(name.get(offset));
+    return true;
+  }
+
+  return false;
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 3140375..4c5ecf0 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -25,12 +25,13 @@
 #define NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
 
 #include "regex-matcher.hpp"
-#include "regex-pseudo-matcher.hpp"
 
 #include <boost/regex.hpp>
 
 namespace ndn {
 
+class RegexPseudoMatcher;
+
 class RegexComponentMatcher : public RegexMatcher
 {
 public:
@@ -57,70 +58,6 @@
   std::vector<shared_ptr<RegexPseudoMatcher>> m_pseudoMatchers;
 };
 
-inline
-RegexComponentMatcher::RegexComponentMatcher(const std::string& expr,
-                                             shared_ptr<RegexBackrefManager> backrefManager,
-                                             bool isExactMatch)
-  : RegexMatcher(expr, EXPR_COMPONENT, std::move(backrefManager))
-  , m_isExactMatch(isExactMatch)
-{
-  compile();
-}
-
-// Re: http://www.boost.org/users/history/version_1_56_0.html
-//
-//   Breaking change: corrected behavior of basic_regex<>::mark_count() to match existing
-//   documentation, basic_regex<>::subexpression(n) changed to match, see
-//   https://svn.boost.org/trac/boost/ticket/9227
-//
-static constexpr size_t BOOST_REGEXP_MARK_COUNT_CORRECTION =
-#if BOOST_VERSION < 105600
-    1;
-#else
-    0;
-#endif
-
-inline void
-RegexComponentMatcher::compile()
-{
-  m_componentRegex = boost::regex(m_expr);
-
-  m_pseudoMatchers.clear();
-  m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
-
-  for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
-    m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
-    m_backrefManager->pushRef(m_pseudoMatchers.back());
-  }
-}
-
-inline bool
-RegexComponentMatcher::match(const Name& name, size_t offset, size_t len)
-{
-  m_matchResult.clear();
-
-  if (m_expr.empty()) {
-    m_matchResult.push_back(name.get(offset));
-    return true;
-  }
-
-  if (!m_isExactMatch)
-    BOOST_THROW_EXCEPTION(Error("Non-exact component search is not supported yet"));
-
-  boost::smatch subResult;
-  std::string targetStr = name.get(offset).toUri();
-  if (boost::regex_match(targetStr, subResult, m_componentRegex)) {
-    for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
-      m_pseudoMatchers[i]->resetMatchResult();
-      m_pseudoMatchers[i]->setMatchResult(subResult[i]);
-    }
-    m_matchResult.push_back(name.get(offset));
-    return true;
-  }
-
-  return false;
-}
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
diff --git a/src/util/regex/regex-component-set-matcher.cpp b/src/util/regex/regex-component-set-matcher.cpp
new file mode 100644
index 0000000..8e39794
--- /dev/null
+++ b/src/util/regex/regex-component-set-matcher.cpp
@@ -0,0 +1,144 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-component-set-matcher.hpp"
+#include "regex-component-matcher.hpp"
+
+namespace ndn {
+
+RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr,
+                                                   shared_ptr<RegexBackrefManager> backrefManager)
+  : RegexMatcher(expr, EXPR_COMPONENT_SET, std::move(backrefManager))
+  , m_isInclusion(true)
+{
+  compile();
+}
+
+void
+RegexComponentSetMatcher::compile()
+{
+  if (m_expr.size() < 2)
+    BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
+
+  switch (m_expr[0]) {
+    case '<':
+      return compileSingleComponent();
+    case '[': {
+      size_t lastIndex = m_expr.size() - 1;
+      if (']' != m_expr[lastIndex])
+        BOOST_THROW_EXCEPTION(Error("Regexp compile error (no matching ']' in " + m_expr + ")"));
+
+      if ('^' == m_expr[1]) {
+        m_isInclusion = false;
+        compileMultipleComponents(2, lastIndex);
+      }
+      else
+        compileMultipleComponents(1, lastIndex);
+      break;
+    }
+    default:
+      BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
+  }
+}
+
+void
+RegexComponentSetMatcher::compileSingleComponent()
+{
+  size_t end = extractComponent(1);
+  if (m_expr.size() != end)
+    BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
+
+  m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(1, end - 2),
+                                                         m_backrefManager));
+}
+
+void
+RegexComponentSetMatcher::compileMultipleComponents(size_t start, size_t lastIndex)
+{
+  size_t index = start;
+  size_t tempIndex = start;
+
+  while (index < lastIndex) {
+    if ('<' != m_expr[index])
+      BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
+
+    tempIndex = index + 1;
+    index = extractComponent(tempIndex);
+    m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(tempIndex, index - tempIndex - 1),
+                                                           m_backrefManager));
+  }
+
+  if (index != lastIndex)
+    BOOST_THROW_EXCEPTION(Error("Not sufficient expr to parse " + m_expr));
+}
+
+bool
+RegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
+{
+  // componentset only matches one component
+  if (len != 1)
+    return false;
+
+  bool isMatched = false;
+  for (const auto& comp : m_components) {
+    if (comp->match(name, offset, len)) {
+      isMatched = true;
+      break;
+    }
+  }
+
+  m_matchResult.clear();
+
+  if (m_isInclusion ? isMatched : !isMatched) {
+    m_matchResult.push_back(name.get(offset));
+    return true;
+  }
+  else
+    return false;
+}
+
+size_t
+RegexComponentSetMatcher::extractComponent(size_t index) const
+{
+  size_t lcount = 1;
+  size_t rcount = 0;
+
+  while (lcount > rcount) {
+    switch (m_expr[index]) {
+      case '<':
+        lcount++;
+        break;
+      case '>':
+        rcount++;
+        break;
+      case 0:
+        BOOST_THROW_EXCEPTION(Error("Square brackets mismatch"));
+        break;
+    }
+    index++;
+  }
+
+  return index;
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 46d8527..3c9fae9 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -24,13 +24,14 @@
 #ifndef NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP
 #define NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP
 
-#include "regex-component-matcher.hpp"
 #include "regex-matcher.hpp"
 
 #include <set>
 
 namespace ndn {
 
+class RegexComponentMatcher;
+
 class RegexComponentSetMatcher : public RegexMatcher
 {
 public:
@@ -66,122 +67,6 @@
   bool m_isInclusion;
 };
 
-inline
-RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr,
-                                                   shared_ptr<RegexBackrefManager> backrefManager)
-  : RegexMatcher(expr, EXPR_COMPONENT_SET, std::move(backrefManager))
-  , m_isInclusion(true)
-{
-  compile();
-}
-
-inline void
-RegexComponentSetMatcher::compile()
-{
-  if (m_expr.size() < 2)
-    BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
-
-  switch (m_expr[0]) {
-    case '<':
-      return compileSingleComponent();
-    case '[': {
-      size_t lastIndex = m_expr.size() - 1;
-      if (']' != m_expr[lastIndex])
-        BOOST_THROW_EXCEPTION(Error("Regexp compile error (no matching ']' in " + m_expr + ")"));
-
-      if ('^' == m_expr[1]) {
-        m_isInclusion = false;
-        compileMultipleComponents(2, lastIndex);
-      }
-      else
-        compileMultipleComponents(1, lastIndex);
-      break;
-    }
-    default:
-      BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
-  }
-}
-
-inline void
-RegexComponentSetMatcher::compileSingleComponent()
-{
-  size_t end = extractComponent(1);
-  if (m_expr.size() != end)
-    BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
-
-  m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(1, end - 2),
-                                                         m_backrefManager));
-}
-
-inline void
-RegexComponentSetMatcher::compileMultipleComponents(size_t start, size_t lastIndex)
-{
-  size_t index = start;
-  size_t tempIndex = start;
-
-  while (index < lastIndex) {
-    if ('<' != m_expr[index])
-      BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
-
-    tempIndex = index + 1;
-    index = extractComponent(tempIndex);
-    m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(tempIndex, index - tempIndex - 1),
-                                                           m_backrefManager));
-  }
-
-  if (index != lastIndex)
-    BOOST_THROW_EXCEPTION(Error("Not sufficient expr to parse " + m_expr));
-}
-
-inline bool
-RegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
-{
-  // componentset only matches one component
-  if (len != 1)
-    return false;
-
-  bool isMatched = false;
-  for (const auto& comp : m_components) {
-    if (comp->match(name, offset, len)) {
-      isMatched = true;
-      break;
-    }
-  }
-
-  m_matchResult.clear();
-
-  if (m_isInclusion ? isMatched : !isMatched) {
-    m_matchResult.push_back(name.get(offset));
-    return true;
-  }
-  else
-    return false;
-}
-
-inline size_t
-RegexComponentSetMatcher::extractComponent(size_t index) const
-{
-  size_t lcount = 1;
-  size_t rcount = 0;
-
-  while (lcount > rcount) {
-    switch (m_expr[index]) {
-      case '<':
-        lcount++;
-        break;
-      case '>':
-        rcount++;
-        break;
-      case 0:
-        BOOST_THROW_EXCEPTION(Error("Square brackets mismatch"));
-        break;
-    }
-    index++;
-  }
-
-  return index;
-}
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP
diff --git a/src/util/regex/regex-matcher.cpp b/src/util/regex/regex-matcher.cpp
new file mode 100644
index 0000000..f460f92
--- /dev/null
+++ b/src/util/regex/regex-matcher.cpp
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-matcher.hpp"
+
+namespace ndn {
+
+RegexMatcher::RegexMatcher(const std::string& expr, const RegexExprType& type,
+                           shared_ptr<RegexBackrefManager> backrefManager)
+  : m_expr(expr)
+  , m_type(type)
+{
+  if (backrefManager)
+    m_backrefManager = std::move(backrefManager);
+  else
+    m_backrefManager = make_shared<RegexBackrefManager>();
+}
+
+RegexMatcher::~RegexMatcher() = default;
+
+bool
+RegexMatcher::match(const Name& name, size_t offset, size_t len)
+{
+  m_matchResult.clear();
+
+  if (recursiveMatch(0, name, offset, len)) {
+    for (size_t i = offset; i < offset + len; i++)
+      m_matchResult.push_back(name.get(i));
+    return true;
+  }
+
+  return false;
+}
+
+bool
+RegexMatcher::recursiveMatch(size_t matcherNo, const Name& name, size_t offset, size_t len)
+{
+  if (matcherNo >= m_matchers.size())
+    return len == 0;
+
+  ssize_t tried = len;
+  auto matcher = m_matchers[matcherNo];
+
+  while (tried >= 0) {
+    if (matcher->match(name, offset, tried) &&
+        recursiveMatch(matcherNo + 1, name, offset + tried, len - tried))
+      return true;
+    tried--;
+  }
+
+  return false;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const RegexMatcher& rm)
+{
+  return os << rm.getExpr();
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-matcher.hpp b/src/util/regex/regex-matcher.hpp
index 5916565..bb18a8f 100644
--- a/src/util/regex/regex-matcher.hpp
+++ b/src/util/regex/regex-matcher.hpp
@@ -56,7 +56,7 @@
                shared_ptr<RegexBackrefManager> backrefManager = nullptr);
 
   virtual
-  ~RegexMatcher() = default;
+  ~RegexMatcher();
 
   virtual bool
   match(const Name& name, size_t offset, size_t len);
@@ -96,56 +96,8 @@
   std::vector<name::Component> m_matchResult;
 };
 
-inline std::ostream&
-operator<<(std::ostream& os, const RegexMatcher& rm)
-{
-  return os << rm.getExpr();
-}
-
-inline
-RegexMatcher::RegexMatcher(const std::string& expr, const RegexExprType& type,
-                           shared_ptr<RegexBackrefManager> backrefManager)
-  : m_expr(expr)
-  , m_type(type)
-{
-  if (backrefManager)
-    m_backrefManager = std::move(backrefManager);
-  else
-    m_backrefManager = make_shared<RegexBackrefManager>();
-}
-
-inline bool
-RegexMatcher::match(const Name& name, size_t offset, size_t len)
-{
-  m_matchResult.clear();
-
-  if (recursiveMatch(0, name, offset, len)) {
-    for (size_t i = offset; i < offset + len; i++)
-      m_matchResult.push_back(name.get(i));
-    return true;
-  }
-
-  return false;
-}
-
-inline bool
-RegexMatcher::recursiveMatch(size_t matcherNo, const Name& name, size_t offset, size_t len)
-{
-  if (matcherNo >= m_matchers.size())
-    return len == 0;
-
-  ssize_t tried = len;
-  auto matcher = m_matchers[matcherNo];
-
-  while (tried >= 0) {
-    if (matcher->match(name, offset, tried) &&
-        recursiveMatch(matcherNo + 1, name, offset + tried, len - tried))
-      return true;
-    tried--;
-  }
-
-  return false;
-}
+std::ostream&
+operator<<(std::ostream& os, const RegexMatcher& rm);
 
 } // namespace ndn
 
diff --git a/src/util/regex/regex-pattern-list-matcher.cpp b/src/util/regex/regex-pattern-list-matcher.cpp
new file mode 100644
index 0000000..9f18441
--- /dev/null
+++ b/src/util/regex/regex-pattern-list-matcher.cpp
@@ -0,0 +1,153 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-pattern-list-matcher.hpp"
+#include "regex-backref-matcher.hpp"
+#include "regex-repeat-matcher.hpp"
+
+namespace ndn {
+
+RegexPatternListMatcher::RegexPatternListMatcher(const std::string& expr,
+                                                 shared_ptr<RegexBackrefManager> backrefManager)
+  : RegexMatcher(expr, EXPR_PATTERN_LIST, std::move(backrefManager))
+{
+  compile();
+}
+
+void
+RegexPatternListMatcher::compile()
+{
+  size_t len = m_expr.size();
+  size_t index = 0;
+  size_t subHead = index;
+
+  while (index < len) {
+    subHead = index;
+
+    if (!extractPattern(subHead, &index))
+      BOOST_THROW_EXCEPTION(Error("Compile error"));
+  }
+}
+
+bool
+RegexPatternListMatcher::extractPattern(size_t index, size_t* next)
+{
+  size_t start = index;
+  size_t end = index;
+  size_t indicator = index;
+
+  switch (m_expr[index]) {
+  case '(':
+    index++;
+    index = extractSubPattern('(', ')', index);
+    indicator = index;
+    end = extractRepetition(index);
+    if (indicator == end) {
+      auto matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(start, end - start),
+                                                      m_backrefManager);
+      m_backrefManager->pushRef(matcher);
+      matcher->lateCompile();
+      m_matchers.push_back(std::move(matcher));
+    }
+    else
+      m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
+                                                           m_backrefManager, indicator - start));
+    break;
+
+  case '<':
+    index++;
+    index = extractSubPattern('<', '>', index);
+    indicator = index;
+    end = extractRepetition(index);
+    m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
+                                                         m_backrefManager, indicator - start));
+    break;
+
+  case '[':
+    index++;
+    index = extractSubPattern('[', ']', index);
+    indicator = index;
+    end = extractRepetition(index);
+    m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
+                                                         m_backrefManager, indicator - start));
+    break;
+
+  default:
+    BOOST_THROW_EXCEPTION(Error("Unexpected syntax"));
+  }
+
+  *next = end;
+  return true;
+}
+
+size_t
+RegexPatternListMatcher::extractSubPattern(const char left, const char right, size_t index)
+{
+  size_t lcount = 1;
+  size_t rcount = 0;
+
+  while (lcount > rcount) {
+    if (index >= m_expr.size())
+      BOOST_THROW_EXCEPTION(Error("Parenthesis mismatch"));
+
+    if (left == m_expr[index])
+      lcount++;
+
+    if (right == m_expr[index])
+      rcount++;
+
+    index++;
+  }
+
+  return index;
+}
+
+size_t
+RegexPatternListMatcher::extractRepetition(size_t index)
+{
+  size_t exprSize = m_expr.size();
+
+  if (index == exprSize)
+    return index;
+
+  if (('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])) {
+    return ++index;
+  }
+
+  if ('{' == m_expr[index]) {
+    while ('}' != m_expr[index]) {
+      index++;
+      if (index == exprSize)
+        break;
+    }
+    if (index == exprSize)
+      BOOST_THROW_EXCEPTION(Error("Missing right brace bracket"));
+    else
+      return ++index;
+  }
+  else {
+    return index;
+  }
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index 7bf0366..79c1d3e 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -50,135 +50,4 @@
 
 } // namespace ndn
 
-#include "regex-backref-matcher.hpp"
-#include "regex-repeat-matcher.hpp"
-
-namespace ndn {
-
-inline
-RegexPatternListMatcher::RegexPatternListMatcher(const std::string& expr,
-                                                 shared_ptr<RegexBackrefManager> backrefManager)
-  : RegexMatcher(expr, EXPR_PATTERN_LIST, std::move(backrefManager))
-{
-  compile();
-}
-
-inline void
-RegexPatternListMatcher::compile()
-{
-  size_t len = m_expr.size();
-  size_t index = 0;
-  size_t subHead = index;
-
-  while (index < len) {
-    subHead = index;
-
-    if (!extractPattern(subHead, &index))
-      BOOST_THROW_EXCEPTION(Error("Compile error"));
-  }
-}
-
-inline bool
-RegexPatternListMatcher::extractPattern(size_t index, size_t* next)
-{
-  size_t start = index;
-  size_t end = index;
-  size_t indicator = index;
-
-  switch (m_expr[index]) {
-  case '(':
-    index++;
-    index = extractSubPattern('(', ')', index);
-    indicator = index;
-    end = extractRepetition(index);
-    if (indicator == end) {
-      auto matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(start, end - start),
-                                                      m_backrefManager);
-      m_backrefManager->pushRef(matcher);
-      matcher->lateCompile();
-      m_matchers.push_back(std::move(matcher));
-    }
-    else
-      m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
-                                                           m_backrefManager, indicator - start));
-    break;
-
-  case '<':
-    index++;
-    index = extractSubPattern('<', '>', index);
-    indicator = index;
-    end = extractRepetition(index);
-    m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
-                                                         m_backrefManager, indicator - start));
-    break;
-
-  case '[':
-    index++;
-    index = extractSubPattern('[', ']', index);
-    indicator = index;
-    end = extractRepetition(index);
-    m_matchers.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start),
-                                                         m_backrefManager, indicator - start));
-    break;
-
-  default:
-    BOOST_THROW_EXCEPTION(Error("Unexpected syntax"));
-  }
-
-  *next = end;
-  return true;
-}
-
-inline size_t
-RegexPatternListMatcher::extractSubPattern(const char left, const char right, size_t index)
-{
-  size_t lcount = 1;
-  size_t rcount = 0;
-
-  while (lcount > rcount) {
-    if (index >= m_expr.size())
-      BOOST_THROW_EXCEPTION(Error("Parenthesis mismatch"));
-
-    if (left == m_expr[index])
-      lcount++;
-
-    if (right == m_expr[index])
-      rcount++;
-
-    index++;
-  }
-
-  return index;
-}
-
-inline size_t
-RegexPatternListMatcher::extractRepetition(size_t index)
-{
-  size_t exprSize = m_expr.size();
-
-  if (index == exprSize)
-    return index;
-
-  if (('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])) {
-    return ++index;
-  }
-
-  if ('{' == m_expr[index]) {
-    while ('}' != m_expr[index]) {
-      index++;
-      if (index == exprSize)
-        break;
-    }
-    if (index == exprSize)
-      BOOST_THROW_EXCEPTION(Error("Missing right brace bracket"));
-    else
-      return ++index;
-  }
-  else {
-    return index;
-  }
-}
-
-} // namespace ndn
-
 #endif // NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP
diff --git a/src/util/regex/regex-pseudo-matcher.cpp b/src/util/regex/regex-pseudo-matcher.cpp
new file mode 100644
index 0000000..5c792d5
--- /dev/null
+++ b/src/util/regex/regex-pseudo-matcher.cpp
@@ -0,0 +1,50 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-pseudo-matcher.hpp"
+
+namespace ndn {
+
+RegexPseudoMatcher::RegexPseudoMatcher()
+  : RegexMatcher("", EXPR_PSEUDO)
+{
+}
+
+void
+RegexPseudoMatcher::setMatchResult(const std::string& str)
+{
+  m_matchResult.push_back(name::Component(reinterpret_cast<const uint8_t*>(str.data()), str.size()));
+}
+
+void
+RegexPseudoMatcher::resetMatchResult()
+{
+  m_matchResult.clear();
+}
+
+void
+RegexPseudoMatcher::compile()
+{
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-pseudo-matcher.hpp b/src/util/regex/regex-pseudo-matcher.hpp
index a2c19a0..628b883 100644
--- a/src/util/regex/regex-pseudo-matcher.hpp
+++ b/src/util/regex/regex-pseudo-matcher.hpp
@@ -44,29 +44,6 @@
   compile() override;
 };
 
-inline
-RegexPseudoMatcher::RegexPseudoMatcher()
-  : RegexMatcher("", EXPR_PSEUDO)
-{
-}
-
-inline void
-RegexPseudoMatcher::setMatchResult(const std::string& str)
-{
-  m_matchResult.push_back(name::Component(reinterpret_cast<const uint8_t*>(str.data()), str.size()));
-}
-
-inline void
-RegexPseudoMatcher::resetMatchResult()
-{
-  m_matchResult.clear();
-}
-
-inline void
-RegexPseudoMatcher::compile()
-{
-}
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_PSEUDO_MATCHER_HPP
diff --git a/src/util/regex/regex-repeat-matcher.cpp b/src/util/regex/regex-repeat-matcher.cpp
new file mode 100644
index 0000000..17986bf
--- /dev/null
+++ b/src/util/regex/regex-repeat-matcher.cpp
@@ -0,0 +1,176 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
+ */
+
+#include "regex-repeat-matcher.hpp"
+#include "regex-backref-matcher.hpp"
+#include "regex-component-set-matcher.hpp"
+
+#include <boost/regex.hpp>
+#include <cstdlib>
+
+namespace ndn {
+
+RegexRepeatMatcher::RegexRepeatMatcher(const std::string& expr,
+                                       shared_ptr<RegexBackrefManager> backrefManager,
+                                       size_t indicator)
+  : RegexMatcher(expr, EXPR_REPEAT_PATTERN, std::move(backrefManager))
+  , m_indicator(indicator)
+{
+  compile();
+}
+
+void
+RegexRepeatMatcher::compile()
+{
+  if ('(' == m_expr[0]) {
+    auto matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
+    m_backrefManager->pushRef(matcher);
+    matcher->lateCompile();
+    m_matchers.push_back(std::move(matcher));
+  }
+  else {
+    m_matchers.push_back(make_shared<RegexComponentSetMatcher>(m_expr.substr(0, m_indicator),
+                                                               m_backrefManager));
+  }
+
+  parseRepetition();
+}
+
+bool
+RegexRepeatMatcher::parseRepetition()
+{
+  size_t exprSize = m_expr.size();
+  const size_t MAX_REPETITIONS = std::numeric_limits<size_t>::max();
+
+  if (exprSize == m_indicator) {
+    m_repeatMin = 1;
+    m_repeatMax = 1;
+    return true;
+  }
+
+  if (exprSize == (m_indicator + 1)) {
+    if ('?' == m_expr[m_indicator]) {
+      m_repeatMin = 0;
+      m_repeatMax = 1;
+      return true;
+    }
+    if ('+' == m_expr[m_indicator]) {
+      m_repeatMin = 1;
+      m_repeatMax = MAX_REPETITIONS;
+      return true;
+    }
+    if ('*' == m_expr[m_indicator]) {
+      m_repeatMin = 0;
+      m_repeatMax = MAX_REPETITIONS;
+      return true;
+    }
+  }
+  else {
+    std::string repeatStruct = m_expr.substr(m_indicator, exprSize - m_indicator);
+    size_t rsSize = repeatStruct.size();
+    size_t min = 0;
+    size_t max = 0;
+
+    if (boost::regex_match(repeatStruct, boost::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]+\\}"))) {
+      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]+,\\}"))) {
+      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]+\\}"))) {
+      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));
+
+    if (min > MAX_REPETITIONS || max > MAX_REPETITIONS || min > max)
+      BOOST_THROW_EXCEPTION(Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
+                                  + " Wrong number " + m_expr));
+
+    m_repeatMin = min;
+    m_repeatMax = max;
+
+    return true;
+  }
+
+  return false;
+}
+
+bool
+RegexRepeatMatcher::match(const Name& name, size_t offset, size_t len)
+{
+  m_matchResult.clear();
+
+  if (m_repeatMin == 0)
+    if (len == 0)
+      return true;
+
+  if (recursiveMatch(0, name, offset, len)) {
+    for (size_t i = offset; i < offset + len; i++)
+      m_matchResult.push_back(name.get(i));
+    return true;
+  }
+
+  return false;
+}
+
+bool
+RegexRepeatMatcher::recursiveMatch(size_t repeat, const Name& name, size_t offset, size_t len)
+{
+  ssize_t tried = len;
+
+  if (0 < len && repeat >= m_repeatMax) {
+    return false;
+  }
+
+  if (0 == len && repeat < m_repeatMin) {
+    return false;
+  }
+
+  if (0 == len && repeat >= m_repeatMin) {
+    return true;
+  }
+
+  auto matcher = m_matchers[0];
+  while (tried >= 0) {
+    if (matcher->match(name, offset, tried) &&
+        recursiveMatch(repeat + 1, name, offset + tried, len - tried))
+      return true;
+    tried--;
+  }
+
+  return false;
+}
+
+} // namespace ndn
diff --git a/src/util/regex/regex-repeat-matcher.hpp b/src/util/regex/regex-repeat-matcher.hpp
index 86af906..de29e02 100644
--- a/src/util/regex/regex-repeat-matcher.hpp
+++ b/src/util/regex/regex-repeat-matcher.hpp
@@ -57,155 +57,4 @@
 
 } // namespace ndn
 
-#include "regex-backref-matcher.hpp"
-#include "regex-component-set-matcher.hpp"
-
-namespace ndn {
-
-inline
-RegexRepeatMatcher::RegexRepeatMatcher(const std::string& expr,
-                                       shared_ptr<RegexBackrefManager> backrefManager,
-                                       size_t indicator)
-  : RegexMatcher(expr, EXPR_REPEAT_PATTERN, std::move(backrefManager))
-  , m_indicator(indicator)
-{
-  compile();
-}
-
-inline void
-RegexRepeatMatcher::compile()
-{
-  if ('(' == m_expr[0]) {
-    auto matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
-    m_backrefManager->pushRef(matcher);
-    matcher->lateCompile();
-    m_matchers.push_back(std::move(matcher));
-  }
-  else {
-    m_matchers.push_back(make_shared<RegexComponentSetMatcher>(m_expr.substr(0, m_indicator),
-                                                               m_backrefManager));
-  }
-
-  parseRepetition();
-}
-
-inline bool
-RegexRepeatMatcher::parseRepetition()
-{
-  size_t exprSize = m_expr.size();
-  const size_t MAX_REPETITIONS = std::numeric_limits<size_t>::max();
-
-  if (exprSize == m_indicator) {
-    m_repeatMin = 1;
-    m_repeatMax = 1;
-    return true;
-  }
-
-  if (exprSize == (m_indicator + 1)) {
-    if ('?' == m_expr[m_indicator]) {
-      m_repeatMin = 0;
-      m_repeatMax = 1;
-      return true;
-    }
-    if ('+' == m_expr[m_indicator]) {
-      m_repeatMin = 1;
-      m_repeatMax = MAX_REPETITIONS;
-      return true;
-    }
-    if ('*' == m_expr[m_indicator]) {
-      m_repeatMin = 0;
-      m_repeatMax = MAX_REPETITIONS;
-      return true;
-    }
-  }
-  else {
-    std::string repeatStruct = m_expr.substr(m_indicator, exprSize - m_indicator);
-    size_t rsSize = repeatStruct.size();
-    size_t min = 0;
-    size_t max = 0;
-
-    if (boost::regex_match(repeatStruct, boost::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]+\\}"))) {
-      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]+,\\}"))) {
-      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]+\\}"))) {
-      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));
-
-    if (min > MAX_REPETITIONS || max > MAX_REPETITIONS || min > max)
-      BOOST_THROW_EXCEPTION(Error(std::string("Error: RegexRepeatMatcher.ParseRepetition():")
-                                  + " Wrong number " + m_expr));
-
-    m_repeatMin = min;
-    m_repeatMax = max;
-
-    return true;
-  }
-
-  return false;
-}
-
-inline bool
-RegexRepeatMatcher::match(const Name& name, size_t offset, size_t len)
-{
-  m_matchResult.clear();
-
-  if (m_repeatMin == 0)
-    if (len == 0)
-      return true;
-
-  if (recursiveMatch(0, name, offset, len)) {
-    for (size_t i = offset; i < offset + len; i++)
-      m_matchResult.push_back(name.get(i));
-    return true;
-  }
-
-  return false;
-}
-
-inline bool
-RegexRepeatMatcher::recursiveMatch(size_t repeat, const Name& name, size_t offset, size_t len)
-{
-  ssize_t tried = len;
-
-  if (0 < len && repeat >= m_repeatMax) {
-    return false;
-  }
-
-  if (0 == len && repeat < m_repeatMin) {
-    return false;
-  }
-
-  if (0 == len && repeat >= m_repeatMin) {
-    return true;
-  }
-
-  auto matcher = m_matchers[0];
-  while (tried >= 0) {
-    if (matcher->match(name, offset, tried) &&
-        recursiveMatch(repeat + 1, name, offset + tried, len - tried))
-      return true;
-    tried--;
-  }
-
-  return false;
-}
-
-} // namespace ndn
-
 #endif // NDN_UTIL_REGEX_REGEX_REPEAT_MATCHER_HPP
