deepak kumar deepak kumar - 1 year ago 69
iOS Question

How to get data from string after particular backslash?

I have a string such as

\home\var\path\uplaod\abc.png
. Now I want to get data from uplaod onwards. Please suggest any function or code?

Answer Source

If path of image is not fixed or order of uplaod is not specific try like this.

let string = "\\home\\var\\path\\uplaod\\abc.png"
if let range = string.range(of: "uplaod") {
    let imagePath = string.substring(from: range.lowerBound)
    print(imagePath)
}

Output

uplaod\abc.png
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download