iOS-Develop(Swift)2016.08.03 12:46


let str = "man|17&woman|19"

let result = str.componentsSeparatedByString("&")

print(result)  // ["man|17", "woman|19]



let charSet = NSCharacterSet(charactersInString: "|^")

let result = str.componentsSeparatedByCharactersInSet(charSet)

print(result)  // ["man","17","woman","19"]



let Array2D = str.componentsSeparatedByString("^").map {

    $0.componentsSeparatedByString("|")

}


print(Array2D) // [["man,"17"],["woman","19"]]








                      
Posted by 꼴찌생각