Skip to main content
edited tags
Link
Adam
  • 27k
  • 8
  • 65
  • 85
deleted 127 characters in body
Source Link
Leo Dabus
  • 237.5k
  • 61
  • 512
  • 624

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)  } 

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)  } 

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) } 
Source Link

Swift Get substring after last occurrence of character in string

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) }