 
   /// Returns the set of keywords in the URI Template
   public var variables: [String] {
-    let expressions = regex.matches(template).map { expression in
+    let expressions = regex.matches(template).map { expression -> String in
       // Removes the { and } from the expression
-      expression.substring(with: expression.characters.index(after: expression.startIndex)..<expression.characters.index(before: expression.endIndex))
+#if swift(>=4.0)
+      return String(expression[expression.characters.index(after: expression.startIndex)..<expression.characters.index(before: expression.endIndex)])
+#else
+      return expression.substring(with: expression.characters.index(after: expression.startIndex)..<expression.characters.index(before: expression.endIndex))
+#endif
     }
 
     return expressions.map { expression -> [String] in

      for op in self.operators {
        if let op = op.op {
          if expression.hasPrefix(op) {
            expression = expression.substring(from: expression.characters.index(after: expression.startIndex))
            break
          }
        }


      return expression.components(separatedBy: ",").map { component in
        if component.hasSuffix("*") {
#if swift(>=4.0)
          return String(component[..<component.characters.index(before: component.endIndex)])
#else
          return component.substring(to: component.characters.index(before: component.endIndex))
#endif
        } else {
          return component
        }
