Patriot Posted February 13, 2008 Share Posted February 13, 2008 I've been trying to create a RegExp using eregi that will allow spaces and letters. When I test it with the online regex testers, everything comes out fine. My site then comes up with different results. ^[a-z\s]+$ For example: United Kingdom doesn't work, while Canada does. Anyone know why this isn't working? Thanks! Quote Link to comment Share on other sites More sharing options...
thebadbad Posted February 13, 2008 Share Posted February 13, 2008 Everything inside square brackets are matches literally, with some few exceptions. So \s inside the brackets will match \ and s literally. Quote Link to comment Share on other sites More sharing options...
Zane Posted February 13, 2008 Share Posted February 13, 2008 use the asterick instead of the plus sign Quote Link to comment Share on other sites More sharing options...
thebadbad Posted February 13, 2008 Share Posted February 13, 2008 You should write a literal space instead of \s. This is working for me: ^[a-z ]+$ Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2008 Share Posted February 13, 2008 Anyone know why this isn't working? \s only works in PREG--not EREG. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.