<commit_before>//
//  RegEx.swift
//  iCalendar
//
//  Created by <NAME> on 07/07/2017.
//  Copyright © 2017 iCalendar. All rights reserved.
//

import Foundation

enum RegEx: String {
    case fold = "(\r?\n)+[ \t]"
    case lineEnding = "\r?\n"
    case escComma = "\\\\,"
    case escSemiColon = "\\\\;"
    case escBackslash = "\\\\{2}"
    case escNewline = "\\\\[nN]"
    
    case newLine = "\n"
    case comma = ","
    case semiColon = ";"
    case backslash = "\\\\"

    static var cache: [RegEx: NSRegularExpression] = [:]
    
    var compiled: NSRegularExpression {
        let nsregex: NSRegularExpression
        
        if case .none = RegEx.cache[self] {
            nsregex = try! NSRegularExpression(pattern: self.rawValue, options: .caseInsensitive)
            RegEx.cache[self] = nsregex            
        }
        else {
            nsregex = RegEx.cache[self]!
        }
        
        return nsregex 
    }
}<commit_msg>Get rid of force unwrap.<commit_after>//
//  RegEx.swift
//  iCalendar
//
//  Created by <NAME> on 07/07/2017.
//  Copyright © 2017 iCalendar. All rights reserved.
//

import Foundation

enum RegEx: String {
    case fold = "(\r?\n)+[ \t]"
    case lineEnding = "\r?\n"
    case escComma = "\\\\,"
    case escSemiColon = "\\\\;"
    case escBackslash = "\\\\{2}"
    case escNewline = "\\\\[nN]"
    
    case newLine = "\n"
    case comma = ","
    case semiColon = ";"
    case backslash = "\\\\"

    static var cache: [RegEx: NSRegularExpression] = [:]
    
    var compiled: NSRegularExpression {
        let nsregex: NSRegularExpression
        
        if let nsr = RegEx.cache[self] {
            nsregex = nsr
        }
        else {
            nsregex = try! NSRegularExpression(pattern: self.rawValue, options: .caseInsensitive)
            RegEx.cache[self] = nsregex            
        }
                
        return nsregex 
    }
}
{'fraction_non_alphanumeric': 0.14383202099737533, 'fraction_numerical': 0.013648293963254593, 'mean_word_length': 1.7228571428571429, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6230685', 'n_tokens_mistral': 658, 'n_tokens_neox': 604, 'n_words': 152}