Answer the question
In order to leave comments, you need to log in
How to parse a complex string in Swift?
There is a line like:
{тут может быть текст} и тут может быть текст {и тут} {и тут} {и просто пробелы между ячейками}
"тут может быть текст"
" и тут может быть текст "
"и тут"
" "
"и тут"
" "
"и просто пробелы между ячейками"
var firstBlockStruct = Array<String>()
for c in incomeText {
if (c == "}") {c = "{"}
}
firstBlockStruct = split(incomeText) {$0 == "{"}
Answer the question
In order to leave comments, you need to log in
I don't know swift, but taking into account your "and then" I suggest:split(incomeText) {$0 == "{" || $0 == "}"}
func replace (var str:String, var replace:Character, var replaced:Character) -> String{
var str1 = ""
println(str)
for Character in str{
var i = Character
if i == replace{
i = replaced
}
str1.append(i)
}
println(str1)
return str1
} // Функция замены символов в строке
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question