I am creating a post upload page that needs to detect when the user types the "@" symbol so it can search the database for the username. My code works for the first "@" in the string but does not work for any additional ones. I want the user to be able to tag as many usernames as they would like. For example: Hey @John did you talk to @Jim today?
This is what I am looking for but it is out of date: How to get substring after last occurrence of character in string: Swift IOS
current code:
var afterEqualsTo = "" if let index = (text.range(of: "@")?.upperBound) { let afterEqualsTo = String(text.suffix(from: index)) print(afterEqualsTo) }