     
     func allRangesOfBeginingsOfTheLinesInRange(range: NSRange) -> [NSRange] {
         
-        var result = [NSRange]()
+        var result: [NSRange] = []
         
         (self as NSString).enumerateSubstringsInRange(range, options: .ByLines) { substr, range, _, _ in
             var firstCharRange = range

    
    func allRangesOfCharacterInBeginigOfWord(char: Character, inRange range: NSRange) -> [NSRange] {
        
        if !letters.characterIsMember(char) {
            return allRangesOfCharacters(char, inRange: range)
        }
        
        var result = [NSRange]()
        var previousChar: Character?
        
        (self as NSString).enumerateSubstringsInRange(range, options: .ByComposedCharacterSequences) { substr, range, _, _ in
            let foundChar = substr?.characters.first!

            if foundChar == char {
                if let prev = previousChar {
                    if punctuation.characterIsMember(prev) {
                        result.append(range)
                    }
                } else {
                    result.append(range)
                }
            }
            
            previousChar = foundChar
        }
        
        return result

extension String {
    
    func allRangesOfCharacters(char: Character, inRange: NSRange) -> [NSRange] {
        let charAsString = String(char)
        
        var result: [NSRange] = []
        
        (self as NSString).enumerateSubstringsInRange(inRange, options: .ByComposedCharacterSequences) { substr, range, _, _ in
            
            guard substr == charAsString else { return }
            
            result.append(range)
        }
        
        return result
