How to split a [String] into rows?

user4964000

I'm using a UITextView to add some values into an array.

I'd like to separate the text from the UITextView into single items if they have a newline (\n) or a comma (,) between them.

var values = self.textLabel.text.componentsSeparatedByString("\n")
for item in values {
    if item != "" {
        cellDataSet.insert([item, false], atIndex: 0)
    }
}
fguchelaar

If you want to separate a String on multiple tokens, use componentsSeparatedByCharactersInSet(_:)

Example:

let text = "This is, some, text; With multiple | seperators"
let separators = NSCharacterSet(charactersInString: ",;|")
let values = text.componentsSeparatedByCharactersInSet(separators)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to split String with ||

分類Dev

How to split the string

分類Dev

How to split the following string

分類Dev

How to split delimited String to multiple rows in Hive using lateral view explode

分類Dev

How to split datatable row in to multiple rows based on character split in .net

分類Dev

How to split the string into 2 with python?

分類Dev

How to Split String, and Include splitter?

分類Dev

How to split a string into multiple columns?

分類Dev

How to split string and display it in a gridview ?

分類Dev

How to split string by specific keywords?

分類Dev

How to split text string to parts?

分類Dev

How to split String with "\" as a delimiter? and also how to replace "\" into ":"?

分類Dev

How to split a long string based on character count

分類Dev

How do I split a string in Rust?

分類Dev

How to split string in GO by array of runes?

分類Dev

How to split string by java regex with look behind?

分類Dev

How to use split a string after a certain length?

分類Dev

How to split string by java regex with look behind?

分類Dev

How to split string with trailing empty strings in result?

分類Dev

R: How to split string and keep part of it?

分類Dev

How to efficiently split a string into lines in J?

分類Dev

How to split a string into chunks of a particular byte size?

分類Dev

How to chose a certain position to split python string by "_"

分類Dev

How to split the string using python3

分類Dev

How to split a string into parts to populate a dict in a loop

分類Dev

How to split a string based on ":" in MS-Excel?

分類Dev

How to split a string and get the last part?

分類Dev

How to use split string to search and populate to listview

分類Dev

How to split pipe-separated column into multiple rows?

Related 関連記事

  1. 1

    How to split String with ||

  2. 2

    How to split the string

  3. 3

    How to split the following string

  4. 4

    How to split delimited String to multiple rows in Hive using lateral view explode

  5. 5

    How to split datatable row in to multiple rows based on character split in .net

  6. 6

    How to split the string into 2 with python?

  7. 7

    How to Split String, and Include splitter?

  8. 8

    How to split a string into multiple columns?

  9. 9

    How to split string and display it in a gridview ?

  10. 10

    How to split string by specific keywords?

  11. 11

    How to split text string to parts?

  12. 12

    How to split String with "\" as a delimiter? and also how to replace "\" into ":"?

  13. 13

    How to split a long string based on character count

  14. 14

    How do I split a string in Rust?

  15. 15

    How to split string in GO by array of runes?

  16. 16

    How to split string by java regex with look behind?

  17. 17

    How to use split a string after a certain length?

  18. 18

    How to split string by java regex with look behind?

  19. 19

    How to split string with trailing empty strings in result?

  20. 20

    R: How to split string and keep part of it?

  21. 21

    How to efficiently split a string into lines in J?

  22. 22

    How to split a string into chunks of a particular byte size?

  23. 23

    How to chose a certain position to split python string by "_"

  24. 24

    How to split the string using python3

  25. 25

    How to split a string into parts to populate a dict in a loop

  26. 26

    How to split a string based on ":" in MS-Excel?

  27. 27

    How to split a string and get the last part?

  28. 28

    How to use split string to search and populate to listview

  29. 29

    How to split pipe-separated column into multiple rows?

ホットタグ

アーカイブ