0

For example i have String of "version/ofswift/developer". and i want print which starts from back side until the specific index like my specific index will be "/" then the answer should be "developer". What code snippet would do that, and being the most swift-like? I can't find any good practice. I hope you will help me to figure it out. Thank In Advance.

Visal Sambo
  • 1,270
  • 1
  • 19
  • 33

1 Answers1

1

Use String method components(separatedBy:) to produce an array and then get the last element using last

let string = "version/ofswift/developer"
let lastComponent = string.components(separatedBy: "/").last
Aleksander Maj
  • 243
  • 3
  • 13