Skip to content

Instantly share code, notes, and snippets.

View 29satnam's full-sized avatar
🎯
Focusing

Satnam 29satnam

🎯
Focusing
View GitHub Profile
@IanKeen
IanKeen / String+componentsSeparatedByStrings.swift
Created November 17, 2015 08:36
String extension to allow splitting a string by multiple components/tokens
extension String {
func componentsSeparatedByStrings(separators: [String]) -> [String] {
return separators.reduce([self]) { result, separator in
return result.flatMap { $0.componentsSeparatedByString(separator) }
}
.map { $0.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) }
}
}
/* Usage */