code: function convertPath(path) {
      function indexOf(ch, startPosition) {
        var pos = path.indexOf(ch, startPosition);
        if (pos === -1)
          return pos;
  
        var slashNumber = 0;
        while (path.charAt(pos - 1 - slashNumber) === '\\')
          ++slashNumber;
  
        if (slashNumber % 2 === 0)
          return pos;
  
        //Skip escaped symbols
        return indexOf(ch, pos + 1);
      }
  
      var match;
  
      //RegEx should be inside loop to reset iteration
      while (match = /{([^}:]+):/g.exec(path)) {
        var deleteBegin = match.index + match[0].length - 1;
        var deleteEnd = deleteBegin;
  
        var unmatched = 1;
        while (unmatched !== 0) {
  
          var open = indexOf('{', deleteEnd + 1);
          var close = indexOf('}', deleteEnd + 1);
  
          if (close === -1)
            throw Error('Unmatched curly brackets in path: ' + path);
  
          if (open !==  -1 && open < close) {
            ++unmatched;
            deleteEnd = open;
          }
          else {
            --unmatched;
            deleteEnd = close;
          }
        }
  
        //For future use: regex itself is
        //path.substring(deleteBegin + 1, deleteEnd)
  
        path = path.slice(0, deleteBegin) + path.slice(deleteEnd);
      }
  
      return path;
    }
docs: Jersey use very strange extension to WADL. See: https://docs.oracle.com/cd/E19776-01/820-4867/6nga7f5nc/index.html They add {<name>: <regex>} template parameters which should be converted to {<name>}. Tricky part is find end of regexp.