Created
October 11, 2019 05:23
-
-
Save strzempa/eec9e92f2f9f78af97df2561ea84f7ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension String { | |
func slice(from firstString: String, to lastString: String) -> String? { | |
return (range(of: firstString)?.upperBound).flatMap { substringFrom in | |
(range(of: lastString, range: substringFrom..<endIndex)?.lowerBound).map { substringTo in | |
String(self[substringFrom..<substringTo]) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment