 
   /// 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

      if expression.hasPrefix("{") && expression.hasSuffix("}") {
        let startIndex = expression.characters.index(after: expression.startIndex)
        let endIndex = expression.characters.index(before: expression.endIndex)
        return self.regexForExpression(expression.substring(with: startIndex..<endIndex))
      } else {
        return NSRegularExpression.escapedPattern(for: expression)
      }

      for op in self.operators {
        if let op = op.op {
          if expression.hasPrefix(op) {
#if swift(>=4.0)
            expression = String(expression[expression.characters.index(after: expression.startIndex)...])
#else
            expression = expression.substring(from: expression.characters.index(after: expression.startIndex))
#endif
            break
          }
        }
