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

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -