Created
September 13, 2017 17:57
-
-
Save anoop4real/472270a5defb0a521a3dba0a2daba65b 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
let string = "This a string split using * and this is left." | |
if let range = string.range(of: "*") { | |
let lastPartIncludingDelimiter = string.substring(from: range.lowerBound) | |
print(lastPartIncludingDelimiter) // print * and this is left. | |
let lastPartExcludingDelimiter = string.substring(from: range.upperBound) | |
print(lastPartExcludingDelimiter) // print and this is left. | |
let firstPartIncludingDelimiter = string.substring(to: range.upperBound) | |
print(firstPartIncludingDelimiter) // print This a string split using * | |
let firstPartExcludingDelimiter = string.substring(to: range.lowerBound) | |
print(firstPartExcludingDelimiter) // print This a string split using | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment