Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2010
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Allow space pregmatch

    I have a preg match that allows valid characters, but how can allow middle spaces? Like for example University Of Insertname. Thanks.

    PHP Code:
    preg_match("#^[A-Za-z']*$#",trim($schoolname))) 

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP Code:
    preg_match("#^[A-Za-z' ]*$#",trim($schoolname))) 
    Or, if you want to include "any whitespace character" such as line feed, etc.:
    PHP Code:
    preg_match("#^[A-Za-z'\s]*$#",trim($schoolname))) 

  • #3
    Regular Coder
    Join Date
    May 2010
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the answer this helps.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •