swift - check URL text as a string in Xcode -
this question has answer here:
i have text field user can use enter linkedin url. however, don't want user able enter url want how can check string entered starts with
https://www.linkedin.com/in/...
you can use string's hasprefix function:
if textfield.text.hasprefix("https://www.linkedin.com/in") { print("string starts https://www.linkedin.com/in") } else { print("string not start https://www.linkedin.com/in") }
Comments
Post a Comment