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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -