Input:
chris@mydomain.com
steve@mydomain.com
Output:
chris
steve
I'm looking to get the substring before the @
character. In Python, I would use something like: myString = myString[:myString.find("@")]
but I think Swift's version is very complex, at least from what I've been reading. Would it be better to bridge to Obj-C in this case, since Swift's indexOf/find function looks something like this mess: Finding index of character in Swift String ?
Something like this, even though it's using arrays, seems to be the simpliest route:
contact = contact.componentsSeparatedByString("@")[0]