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
