0

I have a Text Field that a user can use to enter their LinkedIn URL. However, I don't want the user to be able to just enter any URL they want so how can I check that the string they entered exactly starts with

    https://www.linkedin.com/in/...
Sente
  • 277
  • 4
  • 11

1 Answers1

0

You can use String's hasPrefix function:

if textField.text.hasPrefix("https://www.linkedin.com/in") {
    print("string starts with https://www.linkedin.com/in")
} else {
    print("string does not start with https://www.linkedin.com/in")
}
raver
  • 263
  • 6
  • 14