ardakaraca ardakaraca - 1 year ago 69
Swift Question

How to delete part of string indicated after a character?

This is what I need.

var str = "This is an |#|example text!"

After deleting:

str = "This is an "

Answer Source

This is what you want:

var subdividedStringArray = str.componentsSeparatedByString("|#|")

now you have an array with 2 strings, you can access the first one with:

str = subdividedStringArray[0]


str = subdividedStringArray.first

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download