How to split a string (such as "xPM - yPM") into two strings, Swift

Stewart Hering

If I have a string such as xAM - yPM is it possible to split the string into 2 strings using the - as the point where the string is split?

Christian

You can use the componentsSeparatedByString function:

var splittedArray = yourString.componentsSeparatedByString(" - ")
println(splittedArray[0]) // "xPM"
println(splittedArray[1]) // "yPM"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I split a string into two strings?

From Dev

How to split string into an array into two separate strings

From Dev

Split a string by two strings

From Dev

Split string into two strings by delimiter

From Dev

Split string into two separate strings

From Dev

c++ How to split string into two strings based on the last '.'

From Dev

Split string by two symbols in Swift

From Dev

How to split a string in Swift

From Java

How to split a String into a Stream of Strings?

From Dev

How to split array of strings (string [])?

From Dev

How to split a String into a Stream of Strings?

From Dev

How to split a String into a Stream of Strings?

From Dev

How to split a string into sentences that are strings?

From Dev

Split string with PHP Wordwrap in to two strings?

From Dev

How to split string in two parts

From Dev

How to split string in array in two?

From Dev

How to split a row into two strings and copy the second string in a separate column in SQL?

From Dev

Python: how to split a string by multiple strings

From Dev

How to allow empty strings in String.split()?

From Dev

How to split string with trailing empty strings in result?

From Dev

How to split a string into 2 strings using RegEx?

From Dev

Use Sed to get string between two strings and split

From Dev

Split an array of strings into two arrays, each with a part of the original string

From Dev

How to split a string with two continuous spaces

From Dev

how to split string by two regular expressions

From Dev

How to split Matlab string into two with known suffix?

From Dev

How to split a string into two variables using PHP?

From Dev

How to split string into two parts based on last "/"

From Dev

How to split the string in two arrays in Php

Related Related

  1. 1

    How do I split a string into two strings?

  2. 2

    How to split string into an array into two separate strings

  3. 3

    Split a string by two strings

  4. 4

    Split string into two strings by delimiter

  5. 5

    Split string into two separate strings

  6. 6

    c++ How to split string into two strings based on the last '.'

  7. 7

    Split string by two symbols in Swift

  8. 8

    How to split a string in Swift

  9. 9

    How to split a String into a Stream of Strings?

  10. 10

    How to split array of strings (string [])?

  11. 11

    How to split a String into a Stream of Strings?

  12. 12

    How to split a String into a Stream of Strings?

  13. 13

    How to split a string into sentences that are strings?

  14. 14

    Split string with PHP Wordwrap in to two strings?

  15. 15

    How to split string in two parts

  16. 16

    How to split string in array in two?

  17. 17

    How to split a row into two strings and copy the second string in a separate column in SQL?

  18. 18

    Python: how to split a string by multiple strings

  19. 19

    How to allow empty strings in String.split()?

  20. 20

    How to split string with trailing empty strings in result?

  21. 21

    How to split a string into 2 strings using RegEx?

  22. 22

    Use Sed to get string between two strings and split

  23. 23

    Split an array of strings into two arrays, each with a part of the original string

  24. 24

    How to split a string with two continuous spaces

  25. 25

    how to split string by two regular expressions

  26. 26

    How to split Matlab string into two with known suffix?

  27. 27

    How to split a string into two variables using PHP?

  28. 28

    How to split string into two parts based on last "/"

  29. 29

    How to split the string in two arrays in Php

HotTag

Archive