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! Link to comment https://forums.phpfreaks.com/topic/90812-help-with-regexp-please/ 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. Link to comment https://forums.phpfreaks.com/topic/90812-help-with-regexp-please/#findComment-465773 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 Link to comment https://forums.phpfreaks.com/topic/90812-help-with-regexp-please/#findComment-465792 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 ]+$ Link to comment https://forums.phpfreaks.com/topic/90812-help-with-regexp-please/#findComment-465811 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. Link to comment https://forums.phpfreaks.com/topic/90812-help-with-regexp-please/#findComment-465977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.