 
 import Foundation
 
+/**
+ Regex is a struct that is built off of `NSRegularExpression` to pattern match with. It is to be used to work with Regular Expression with `Strings`. Please refer to `NSRegularExpression` for the regular expression characters and [http://userguide.icu-project.org/strings/regexp](http://userguide.icu-project.org/strings/regexp) for ICU regular expressions.
+*/
 public struct Regex {
     
     private var regexPattern: NSRegularExpression

        }
    }
    
    public func toString() -> String {
        return regexPattern.pattern
    }
    
    internal func matchWithPattern(str: String) -> Match {
        let results = regexPattern.matchesInString(str, options: .ReportCompletion, range: NSRange(location: 0, length: str.startIndex.distanceTo(str.endIndex)))
        var components = [(String, Range<String.Index>)]()

        return Match(components: components)
    }
    
    /**
     Replaces regex matches in string.
     - Parameter str: the `String` to find matches in
     - Parameter replacement: `String` to replace in the matches
     - Returns: A new `String` with the matches replaced
     */
    internal func replaceMatchesInString(str: String, replacement: String) -> String {
        let replaceString = NSMutableString(string: str)
        regexPattern.replaceMatchesInString(replaceString, options: .ReportCompletion, range: NSRange(location: 0, length: str.startIndex.distanceTo(str.endIndex)), withTemplate: replacement)
        return replaceString as String
    }
    
    /**
     Searches the string to find any match.
     - Parameter str: the `String` to find a match in
     - Returns: An optional `Int` of the location of the match
     */
    internal func search(str: String) -> Int? {
        if let result = regexPattern.firstMatchInString(str, options: .ReportCompletion, range: NSRange(location: 0, length: str.startIndex.distanceTo(str.endIndex))) {
            return result.range.location
        }
        return nil
    }
    
    /// The `Match` struct holds the values of a regex match from pattern matching with a string. Uses its methods to access different values of the matching result.
    public struct Match {
        /// A collection of a tuple object with a value of the substring and the range of that substring from the string it was matched in/
        public let components: [(String, Range<String.Index>)]
        
        ///  A collection of just the substrings that were found in the match.
        public func subStrings() -> [String] {
            return components.map {
                $0.0
            }
        }
        
        ///  A collection of just the substring ranges that were found in the match.
        public func ranges() -> [Range<String.Index>] {
            return components.map {
                $0.1
