diff --git a/src/util/regex/regex-backref-matcher.hpp b/src/util/regex/regex-backref-matcher.hpp
index e2eabe8..aa00605 100644
--- a/src/util/regex/regex-backref-matcher.hpp
+++ b/src/util/regex/regex-backref-matcher.hpp
@@ -18,17 +18,17 @@
 {
 public:
   RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
-    
+
   virtual ~RegexBackrefMatcher(){}
 
-  void 
+  void
   lateCompile()
   {
     compile();
   }
 
 protected:
-  virtual void 
+  virtual void
   compile();
 };
 
@@ -44,11 +44,11 @@
   // compile();
 }
 
-inline void 
+inline void
 RegexBackrefMatcher::compile()
 {
   int lastIndex = m_expr.size() - 1;
-  if('(' == m_expr[0] && ')' == m_expr[lastIndex]){
+  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]){
     // m_backRefManager->pushRef(this);
 
     shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager));
@@ -63,5 +63,3 @@
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
-
-
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 50cb8de..34bcba7 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -25,13 +25,13 @@
    * @param backRefManager The back reference manager
    * @param exact The flag to provide exact match
    */
-  RegexComponentMatcher(const std::string& expr, 
-                        ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, 
+  RegexComponentMatcher(const std::string& expr,
+                        ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
                         bool exact = true);
-    
+
   virtual ~RegexComponentMatcher() {};
 
-  virtual bool 
+  virtual bool
   match(const Name & name, const int & offset, const int &len = 1);
 
 protected:
@@ -39,20 +39,20 @@
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
-    
+
 private:
   bool m_exact;
   boost::regex m_componentRegex;
   std::vector<ptr_lib::shared_ptr<RegexPseudoMatcher> > m_pseudoMatcher;
-    
+
 };
 
 
 inline
-RegexComponentMatcher::RegexComponentMatcher (const std::string& expr, 
-                                              ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, 
+RegexComponentMatcher::RegexComponentMatcher (const std::string& expr,
+                                              ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
                                               bool exact)
   : RegexMatcher (expr, EXPR_COMPONENT, backRefManager),
     m_exact(exact)
@@ -62,7 +62,7 @@
   // _LOG_TRACE ("Exit RegexComponentMatcher Constructor: ");
 }
 
-inline void 
+inline void
 RegexComponentMatcher::compile ()
 {
   // _LOG_TRACE ("Enter RegexComponentMatcher::compile");
@@ -78,7 +78,7 @@
       m_pseudoMatcher.push_back(pMatcher);
       m_backrefManager->pushRef(ptr_lib::static_pointer_cast<RegexMatcher>(pMatcher));
     }
-    
+
 
   // _LOG_TRACE ("Exit RegexComponentMatcher::compile");
 }
@@ -90,17 +90,17 @@
 
   m_matchResult.clear();
 
-  if("" == m_expr)
+  if ("" == m_expr)
     {
       m_matchResult.push_back(name.get(offset));
       return true;
     }
 
-  if(true == m_exact)
+  if (true == m_exact)
     {
       boost::smatch subResult;
       std::string targetStr = name.get(offset).toEscapedString();
-      if(boost::regex_match(targetStr, subResult, m_componentRegex))
+      if (boost::regex_match(targetStr, subResult, m_componentRegex))
         {
           for (size_t i = 1; i < m_componentRegex.mark_count(); i++)
             {
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 4039388..5aed58f 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -24,19 +24,19 @@
    * @param exact The flag to provide exact match
    * @param backRefNum The starting back reference number
    */
-  RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);    
+  RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
 
   virtual ~RegexComponentSetMatcher();
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len = 1);
 
-protected:    
+protected:
   /**
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
 
 private:
@@ -45,7 +45,7 @@
 
   void
   compileSingleComponent();
-    
+
   void
   compileMultipleComponents(const int start, const int lastIndex);
 
@@ -57,7 +57,8 @@
 
 
 inline
-RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager)
+RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr,
+                                                   shared_ptr<RegexBackrefManager> backRefManager)
   : RegexMatcher(expr, EXPR_COMPONENT_SET, backRefManager),
     m_include(true)
 {
@@ -75,20 +76,20 @@
   //   delete *it;
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compile()
 {
-  switch(m_expr[0]){
+  switch (m_expr[0]){
   case '<':
     return compileSingleComponent();
   case '[':
     {
       int lastIndex = m_expr.size() - 1;
-      if(']' != m_expr[lastIndex])
+      if (']' != m_expr[lastIndex])
         throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compile(): ")
                                   + " No matched ']' " + m_expr);
-      
-      if('^' == m_expr[1]){
+
+      if ('^' == m_expr[1]){
         m_include = false;
         compileMultipleComponents(2, lastIndex);
       }
@@ -102,52 +103,55 @@
   }
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compileSingleComponent()
 {
   size_t end = extractComponent(1);
 
   if (m_expr.size() != end)
     {
-      throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileSingleComponent: ")
-                                + m_expr);
+      throw RegexMatcher::Error(
+        std::string("Error: RegexComponentSetMatcher.compileSingleComponent: ") + m_expr);
     }
   else
     {
       shared_ptr<RegexComponentMatcher> component =
         make_shared<RegexComponentMatcher>(m_expr.substr(1, end - 2), m_backrefManager);
-      
-      m_components.insert(component);      
+
+      m_components.insert(component);
     }
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compileMultipleComponents(const int start, const int lastIndex)
 {
   int index = start;
   int tmp_index = start;
-    
+
   while(index < lastIndex){
-    if('<' != m_expr[index])
-      throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ")
-                                + "Component expr error " + m_expr);
-      
+    if ('<' != m_expr[index])
+      throw RegexMatcher::Error(
+        std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ") +
+        "Component expr error " + m_expr);
+
     tmp_index = index + 1;
     index = extractComponent(tmp_index);
 
     shared_ptr<RegexComponentMatcher> component =
-      make_shared<RegexComponentMatcher>(m_expr.substr(tmp_index, index - tmp_index - 1), m_backrefManager);
-    
+      make_shared<RegexComponentMatcher>(m_expr.substr(tmp_index, index - tmp_index - 1),
+                                         m_backrefManager);
+
     m_components.insert(component);
   }
-    
-  if(index != lastIndex)
-    throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ")
-                              + "Not sufficient expr to parse " + m_expr);        
+
+  if (index != lastIndex)
+    throw RegexMatcher::Error(
+      std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ") +
+      "Not sufficient expr to parse " + m_expr);
 }
 
-inline bool 
-RegexComponentSetMatcher::match(const Name & name, const int & offset, const int & len)
+inline bool
+RegexComponentSetMatcher::match(const Name& name, const int& offset, const int& len)
 {
   bool matched = false;
 
@@ -161,13 +165,13 @@
        it != m_components.end();
        ++it)
     {
-      if((*it)->match(name, offset, len))
+      if ((*it)->match(name, offset, len))
         {
           matched = true;
           break;
         }
     }
-    
+
   m_matchResult.clear();
 
   if (m_include ? matched : !matched)
@@ -175,18 +179,18 @@
       m_matchResult.push_back(name.get(offset));
       return true;
     }
-  else 
+  else
     return false;
 }
 
-inline int 
+inline int
 RegexComponentSetMatcher::extractComponent(int index)
 {
   int lcount = 1;
   int rcount = 0;
 
   while(lcount > rcount){
-    switch(m_expr[index]){
+    switch (m_expr[index]){
     case '<':
       lcount++;
       break;
diff --git a/src/util/regex/regex-matcher.hpp b/src/util/regex/regex-matcher.hpp
index 0d34311..d62ab41 100644
--- a/src/util/regex/regex-matcher.hpp
+++ b/src/util/regex/regex-matcher.hpp
@@ -18,7 +18,15 @@
 class RegexMatcher
 {
 public:
-  struct Error : public std::runtime_error { Error(const std::string& what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
 
   enum RegexExprType{
     EXPR_TOP,
@@ -26,52 +34,52 @@
     EXPR_PATTERNLIST,
 
     EXPR_REPEAT_PATTERN,
-      
+
     EXPR_BACKREF,
     EXPR_COMPONENT_SET,
     EXPR_COMPONENT,
 
     EXPR_PSEUDO
-  };    
+  };
 
-  RegexMatcher(const std::string& expr, 
-               const RegexExprType& type,  
+  RegexMatcher(const std::string& expr,
+               const RegexExprType& type,
                shared_ptr<RegexBackrefManager> backrefManager = shared_ptr<RegexBackrefManager>());
 
-  virtual 
+  virtual
   ~RegexMatcher();
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len);
 
   /**
    * @brief get the matched name components
    * @returns the matched name components
    */
-  const std::vector<name::Component>& 
+  const std::vector<name::Component>&
   getMatchResult() const
   { return m_matchResult; }
 
   const std::string&
   getExpr() const
-  { return m_expr; } 
+  { return m_expr; }
 
 protected:
   /**
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile() = 0;
 
 private:
-  bool 
+  bool
   recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len);
 
 
 protected:
   const std::string m_expr;
-  const RegexExprType m_type; 
+  const RegexExprType m_type;
   shared_ptr<RegexBackrefManager> m_backrefManager;
   std::vector<shared_ptr<RegexMatcher> > m_matcherList;
   std::vector<name::Component> m_matchResult;
@@ -84,14 +92,14 @@
 namespace ndn {
 
 inline
-RegexMatcher::RegexMatcher(const std::string& expr, 
-                           const RegexExprType& type,  
-                           shared_ptr<RegexBackrefManager> backrefManager) 
-  : m_expr(expr), 
+RegexMatcher::RegexMatcher(const std::string& expr,
+                           const RegexExprType& type,
+                           shared_ptr<RegexBackrefManager> backrefManager)
+  : m_expr(expr),
     m_type(type),
     m_backrefManager(backrefManager)
 {
-  if(NULL == m_backrefManager)
+  if (NULL == m_backrefManager)
     m_backrefManager = make_shared<RegexBackrefManager>();
 }
 
@@ -100,7 +108,7 @@
 {
 }
 
-inline bool 
+inline bool
 RegexMatcher::match (const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexMatcher::match");
@@ -108,7 +116,7 @@
 
   m_matchResult.clear();
 
-  if(recursiveMatch(0, name, offset, len))
+  if (recursiveMatch(0, name, offset, len))
     {
       for(int i = offset; i < offset + len ; i++)
         m_matchResult.push_back(name.get(i));
@@ -122,23 +130,23 @@
   // _LOG_TRACE ("Exit RegexMatcher::match");
   return result;
 }
-  
-inline bool 
+
+inline bool
 RegexMatcher::recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len)
 {
   // _LOG_TRACE ("Enter RegexMatcher::recursiveMatch");
 
   int tried = len;
 
-  if(mId >= m_matcherList.size())
+  if (mId >= m_matcherList.size())
     return (len != 0 ? false : true);
-    
+
   shared_ptr<RegexMatcher> matcher = m_matcherList[mId];
 
   while(tried >= 0)
     {
-      if(matcher->match(name, offset, tried) && recursiveMatch(mId + 1, name, offset + tried, len - tried))
-        return true;      
+      if (matcher->match(name, offset, tried) && recursiveMatch(mId + 1, name, offset + tried, len - tried))
+        return true;
       tried--;
     }
 
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index 3ae74f1..12e3c68 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -20,21 +20,21 @@
 {
 public:
   RegexPatternListMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
-    
+
   virtual ~RegexPatternListMatcher(){};
 
-protected:    
-  virtual void 
+protected:
+  virtual void
   compile();
 
 private:
-  bool 
+  bool
   extractPattern(int index, int* next);
-    
-  int 
+
+  int
   extractSubPattern(const char left, const char right, size_t index);
-    
-  int 
+
+  int
   extractRepetition(size_t index);
 
 private:
@@ -53,38 +53,38 @@
 {
   compile();
 }
-  
-inline void 
+
+inline void
 RegexPatternListMatcher::compile()
 {
   const int len = m_expr.size();
   int index = 0;
   int subHead = index;
-    
+
   while(index < len){
     subHead = index;
 
-    if(!extractPattern(subHead, &index))
+    if (!extractPattern(subHead, &index))
       throw RegexMatcher::Error("RegexPatternListMatcher compile: cannot compile");
   }
 }
 
-inline bool 
+inline bool
 RegexPatternListMatcher::extractPattern(int index, int* next)
 {
   // std::string errMsg = "Error: RegexPatternListMatcher.ExtractSubPattern(): ";
-    
+
   const int start = index;
   int end = index;
   int indicator = index;
 
-  switch(m_expr[index]){
+  switch (m_expr[index]){
   case '(':
     index++;
     index = extractSubPattern('(', ')', index);
     indicator = index;
     end = extractRepetition(index);
-    if(indicator == end){
+    if (indicator == end){
       shared_ptr<RegexMatcher> matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(start, end - start), m_backrefManager);
       m_backrefManager->pushRef(matcher);
       boost::dynamic_pointer_cast<RegexBackrefMatcher>(matcher)->lateCompile();
@@ -94,7 +94,7 @@
     else
       m_matcherList.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start), m_backrefManager, indicator - start));
     break;
-      
+
   case '<':
     index++;
     index = extractSubPattern ('<', '>', index);
@@ -119,8 +119,8 @@
 
   return true;
 }
-  
-inline int 
+
+inline int
 RegexPatternListMatcher::extractSubPattern(const char left, const char right, size_t index)
 {
   size_t lcount = 1;
@@ -128,13 +128,13 @@
 
   while(lcount > rcount){
 
-    if(index >= m_expr.size())
+    if (index >= m_expr.size())
       throw RegexMatcher::Error("Error: parenthesis mismatch");
 
-    if(left == m_expr[index])
+    if (left == m_expr[index])
       lcount++;
 
-    if(right == m_expr[index])
+    if (right == m_expr[index])
       rcount++;
 
     index++;
@@ -142,25 +142,25 @@
   return index;
 }
 
-inline int 
+inline int
 RegexPatternListMatcher::extractRepetition(size_t index)
 {
   size_t exprSize = m_expr.size();
 
-  if(index == exprSize)
+  if (index == exprSize)
     return index;
-    
-  if(('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])){
+
+  if (('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])){
     return ++index;
   }
-    
-  if('{' == m_expr[index]){
+
+  if ('{' == m_expr[index]){
     while('}' != m_expr[index]){
       index++;
-      if(index == exprSize)
+      if (index == exprSize)
         break;
     }
-    if(index == exprSize)
+    if (index == exprSize)
       throw RegexMatcher::Error(std::string("Error: RegexPatternListMatcher.ExtractRepetition(): ")
                                 + "Missing right brace bracket");
     else
diff --git a/src/util/regex/regex-repeat-matcher.hpp b/src/util/regex/regex-repeat-matcher.hpp
index fb42042..5eefbd1 100644
--- a/src/util/regex/regex-repeat-matcher.hpp
+++ b/src/util/regex/regex-repeat-matcher.hpp
@@ -20,10 +20,10 @@
 {
 public:
   RegexRepeatMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager, int indicator);
-    
+
   virtual ~RegexRepeatMatcher(){}
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len);
 
 protected:
@@ -31,19 +31,19 @@
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
 
 private:
-  bool 
+  bool
   parseRepetition();
 
-  bool 
+  bool
   recursiveMatch (int repeat,
-                  const Name & name,
-                  const int & offset,
-                  const int &len);
-  
+                  const Name& name,
+                  const int& offset,
+                  const int&len);
+
 private:
   int m_indicator;
   int m_repeatMin;
@@ -67,14 +67,14 @@
   // _LOG_TRACE ("Exit RegexRepeatMatcher Constructor");
 }
 
-inline void 
+inline void
 RegexRepeatMatcher::compile()
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::compile");
-    
+
   shared_ptr<RegexMatcher> matcher;
 
-  if('(' == m_expr[0]){
+  if ('(' == m_expr[0]){
     matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
     m_backrefManager->pushRef(matcher);
     boost::dynamic_pointer_cast<RegexBackrefMatcher>(matcher)->lateCompile();
@@ -83,40 +83,40 @@
     matcher = make_shared<RegexComponentSetMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
   }
   m_matcherList.push_back(matcher);
-      
+
   parseRepetition();
 
   // _LOG_TRACE ("Exit RegexRepeatMatcher::compile");
 
 }
 
-inline bool 
+inline bool
 RegexRepeatMatcher::parseRepetition()
 {
   // _LOG_DEBUG ("Enter RegexRepeatMatcher::ParseRepetition()" << m_expr << " indicator: " << m_indicator);
-    
+
   int exprSize = m_expr.size();
   int intMax = std::numeric_limits<int>::max();
-    
-  if(exprSize == m_indicator){
+
+  if (exprSize == m_indicator){
     m_repeatMin = 1;
     m_repeatMax = 1;
 
     return true;
   }
   else{
-    if(exprSize == (m_indicator + 1)){
-      if('?' == m_expr[m_indicator]){
+    if (exprSize == (m_indicator + 1)){
+      if ('?' == m_expr[m_indicator]){
         m_repeatMin = 0;
         m_repeatMax = 1;
         return true;
       }
-      if('+' == m_expr[m_indicator]){
+      if ('+' == m_expr[m_indicator]){
         m_repeatMin = 1;
         m_repeatMax = intMax;
         return true;
       }
-      if('*' == m_expr[m_indicator]){
+      if ('*' == m_expr[m_indicator]){
         m_repeatMin = 0;
         m_repeatMax = intMax;
         return true;
@@ -128,36 +128,36 @@
       int min = 0;
       int max = 0;
 
-      if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,[0-9]+\\}"))){
+      if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,[0-9]+\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = atoi(repeatStruct.substr(1, separator - 1).c_str());
         max = atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).c_str());
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{,[0-9]+\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{,[0-9]+\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = 0;
         max = atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).c_str());
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = atoi(repeatStruct.substr(1, separator).c_str());
         max = intMax;
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+\\}"))){
         min = atoi(repeatStruct.substr(1, rsSize - 1).c_str());
         max = min;
       }
       else
         throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
                                   + "Unrecognized format "+ m_expr);
-        
-      if(min > intMax || max > intMax || min > max)
+
+      if (min > intMax || max > intMax || min > max)
         throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
                                   + "Wrong number " + m_expr);
-          
+
       m_repeatMin = min;
       m_repeatMax = max;
-        
+
       return true;
     }
   }
@@ -165,7 +165,7 @@
 }
 
 inline bool
-RegexRepeatMatcher::match(const Name & name, const int & offset, const int & len)
+RegexRepeatMatcher::match(const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::match");
 
@@ -185,8 +185,8 @@
     return false;
 }
 
-inline bool 
-RegexRepeatMatcher::recursiveMatch(int repeat, const Name & name, const int & offset, const int & len)
+inline bool
+RegexRepeatMatcher::recursiveMatch(int repeat, const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::recursiveMatch");
 
@@ -213,7 +213,7 @@
       // _LOG_DEBUG("Match Succeed: No more components && reach m_repeatMin");
       return true;
     }
-    
+
   while(tried >= 0)
     {
       // _LOG_DEBUG("Attempt tried: " << tried);
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index d3b8271..78cb389 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -27,19 +27,19 @@
   // delete m_backRefManager;
 }
 
-void 
+void
 RegexTopMatcher::compile()
 {
   std::string errMsg = "Error: RegexTopMatcher.Compile(): ";
 
   std::string expr = m_expr;
 
-  if('$' != expr[expr.size() - 1])
+  if ('$' != expr[expr.size() - 1])
     expr = expr + "<.*>*";
   else
     expr = expr.substr(0, expr.size()-1);
 
-  if('^' != expr[0])
+  if ('^' != expr[0])
     m_secondaryMatcher = make_shared<RegexPatternListMatcher>(boost::cref("<.*>*" + expr),
                                                               boost::cref(m_secondaryBackRefManager));
   else
@@ -49,14 +49,14 @@
                                                           boost::cref(m_primaryBackRefManager));
 }
 
-bool 
-RegexTopMatcher::match(const Name & name)
+bool
+RegexTopMatcher::match(const Name& name)
 {
   m_secondaryUsed = false;
 
   m_matchResult.clear();
 
-  if(m_primaryMatcher->match(name, 0, name.size()))
+  if (m_primaryMatcher->match(name, 0, name.size()))
     {
       m_matchResult = m_primaryMatcher->getMatchResult();
       return true;
@@ -72,25 +72,25 @@
       return false;
     }
 }
-  
-bool 
-RegexTopMatcher::match (const Name & name, const int & offset, const int & len)
+
+bool
+RegexTopMatcher::match (const Name& name, const int& offset, const int& len)
 {
   return match(name);
 }
 
-Name 
+Name
 RegexTopMatcher::expand (const std::string& expandStr)
 {
   Name result;
-    
+
   shared_ptr<RegexBackrefManager> backRefManager = (m_secondaryUsed ? m_secondaryBackRefManager : m_primaryBackRefManager);
-    
+
   int backRefNum = backRefManager->size();
 
   std::string expand;
-    
-  if(expandStr != "")
+
+  if (expandStr != "")
     expand = expandStr;
   else
     expand = m_expand;
@@ -99,22 +99,22 @@
   while (offset < expand.size())
     {
       std::string item = getItemFromExpand(expand, offset);
-      if(item[0] == '<')
+      if (item[0] == '<')
         {
           result.append(item.substr(1, item.size() - 2));
         }
-      if(item[0] == '\\')
+      if (item[0] == '\\')
         {
 
           int index = atoi(item.substr(1, item.size() - 1).c_str());
 
-          if(0 == index){
+          if (0 == index){
             std::vector<name::Component>::iterator it = m_matchResult.begin();
             std::vector<name::Component>::iterator end = m_matchResult.end();
             for(; it != end; it++)
               result.append (*it);
           }
-          else if(index <= backRefNum)
+          else if (index <= backRefNum)
             {
               std::vector<name::Component>::const_iterator it = backRefManager->getBackRef (index - 1)->getMatchResult ().begin();
               std::vector<name::Component>::const_iterator end = backRefManager->getBackRef (index - 1)->getMatchResult ().end();
@@ -123,7 +123,7 @@
             }
           else
             throw RegexMatcher::Error("Exceed the range of back reference!");
-        }   
+        }
     }
   return result;
 }
@@ -133,38 +133,38 @@
 {
   size_t begin = offset;
 
-  if(expand[offset] == '\\')
+  if (expand[offset] == '\\')
     {
       offset++;
-      if(offset >= expand.size())
+      if (offset >= expand.size())
         throw RegexMatcher::Error("wrong format of expand string!");
 
       while(expand[offset] <= '9' and expand[offset] >= '0'){
         offset++;
-        if(offset > expand.size())
+        if (offset > expand.size())
           throw RegexMatcher::Error("wrong format of expand string!");
       }
-      if(offset > begin + 1)
+      if (offset > begin + 1)
         return expand.substr(begin, offset - begin);
       else
         throw RegexMatcher::Error("wrong format of expand string!");
     }
-  else if(expand[offset] == '<')
+  else if (expand[offset] == '<')
     {
       offset++;
-      if(offset >= expand.size())
+      if (offset >= expand.size())
         throw RegexMatcher::Error("wrong format of expand string!");
-        
+
       size_t left = 1;
       size_t right = 0;
       while(right < left)
         {
-          if(expand[offset] == '<')
+          if (expand[offset] == '<')
             left++;
-          if(expand[offset] == '>')
-            right++;            
+          if (expand[offset] == '>')
+            right++;
           offset++;
-          if(offset >= expand.size())
+          if (offset >= expand.size())
             throw RegexMatcher::Error("wrong format of expand string!");
         }
       return expand.substr(begin, offset - begin);
@@ -178,7 +178,7 @@
 {
   Name::const_iterator it = name.begin();
   std::string regexStr("^");
-    
+
   for(; it != name.end(); it++)
     {
       regexStr.append("<");
@@ -186,7 +186,7 @@
       regexStr.append(">");
     }
 
-  if(hasAnchor)
+  if (hasAnchor)
     regexStr.append("$");
 
   return make_shared<RegexTopMatcher>(boost::cref(regexStr));
@@ -199,7 +199,7 @@
   for(size_t i = 0; i < str.size(); i++)
     {
       char c = str[i];
-      switch(c)
+      switch (c)
         {
         case '.':
         case '[':
