         return NSString(string: self).length
     }
 
+    mutating func trim(string: String) {
+        self = self.stringByTrimmingString(string)
+    }
+
     mutating func URLEncode() {
+        if let string = URLEncodedString() {
+            self = string
+        }
+    }
+
+    mutating func replaceSpacesWithDashes() {
+        self = stringByReplacingSpacesWithDashes()
+    }
+
+    mutating func replaceCapitalsWithUnderscores() {
+        self = stringByConvertingToNamingFormat(.Underscores)
+    }
+
+    func stringByLowercasingFirstLetter() -> String {
+        let start = startIndex.successor()
+        return substringToIndex(start).lowercaseString + substringWithRange(Range<Index>(start: start, end: endIndex))
+    }
+
+    func stringByUppercasingFirstLetter() -> String {
+        let start = startIndex.successor()
+        return substringToIndex(start).uppercaseString + substringWithRange(Range<Index>(start: start, end: endIndex))
+    }
+
+    func stringByTrimmingString(string: String) -> String {
+        let cfString = NSMutableString(string: self) as CFMutableString
+        CFStringTrim(cfString, string)
+        return cfString as String
+    }
+
+    func URLEncodedString() -> String? {
         if let string = stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) {
-            self = string
-        }
-    }
-
-    mutating func slugify() throws {
-        let regex = try NSRegularExpression(pattern: "[ ]", options: NSRegularExpressionOptions())
-        self = regex.stringByReplacingMatchesInString(self, options: NSMatchingOptions(), range: self.range(), withTemplate: "-").lowercaseString
+            return string
+        }
+        else {
+            return nil
+        }
+    }
+
+    func stringByReplacingSpacesWithDashes() -> String {
+        let regexOptions = NSRegularExpressionOptions()
+        let regex = try! NSRegularExpression(pattern: "[ ]", options: regexOptions)
+        return regex.stringByReplacingMatchesInString(self, options: NSMatchingOptions(), range: range(), withTemplate: "-").lowercaseString as String
+    }
+
+    public func stringByConvertingToNamingFormat(naming: VariableNamingFormat) -> String {
+        switch naming {
+        case .Underscores:
+            let regex = try! NSRegularExpression(pattern: "([A-Z]+)", options: NSRegularExpressionOptions())
+            let string = NSMutableString(string: self)
+            regex.replaceMatchesInString(string, options: NSMatchingOptions(), range: range(), withTemplate: "_$0")
+            return string.stringByTrimmingString("_").lowercaseString
+
+        case .CamelCase:
+            fatalError("Not implemented")
+
+        case .PascalCase:
+            fatalError("Not implemented")
+        }
     }
 }
 

     - date: February 17, 2016
     */
    func range() -> NSRange
}

public protocol LHSURLStringType {
    mutating func URLEncode()
    mutating func slugify() throws
}

extension String: LHSStringType, LHSURLStringType {}

    func slugify() {
        return String(self).slugify()
    }

    func stringByLowercasingFirstLetter() -> String {
        return String(self).stringByLowercasingFirstLetter()
    }

    func stringByUppercasingFirstLetter() -> String {
        return String(self).stringByLowercasingFirstLetter()
    }

    func stringByReplacingSpacesWithDashes() -> String {
        return String(self).stringByReplacingSpacesWithDashes()
    }

    func stringByConvertingToNamingFormat(naming: VariableNamingFormat) -> String {
        return String(self).stringByConvertingToNamingFormat(naming)
    }

    func stringByTrimmingString(string: String) -> String {
        return String(self).stringByTrimmingString(string)
    }
}

public extension NSAttributedString {
