Daney11 Posted February 19, 2008 Share Posted February 19, 2008 Hey im using function CharacterFilter($value){ $value = stripslashes($value); $value = trim($value); if (eregi ('^[A-Za-z0-9-]{2,35}$', $value)) { return true; } return false; } How would i be able to add more characters such as _ ^ " etc Link to comment https://forums.phpfreaks.com/topic/91957-eregi/ Share on other sites More sharing options...
effigy Posted February 19, 2008 Share Posted February 19, 2008 Add them to the character class. A-Z0-9_ can be changed to \w: [-\w"^] Link to comment https://forums.phpfreaks.com/topic/91957-eregi/#findComment-470964 Share on other sites More sharing options...
Daney11 Posted February 19, 2008 Author Share Posted February 19, 2008 I cant seem to get that working. If i want to allow ! " ^ : _ - . a-z A-Z 0-9 Just those.... how would i do it? Thanks Link to comment https://forums.phpfreaks.com/topic/91957-eregi/#findComment-470976 Share on other sites More sharing options...
effigy Posted February 19, 2008 Share Posted February 19, 2008 Ack! My mistake. \w only works under PREG, which you could switch to: preg_match('/\A[-\w.^"!:]+\z/', $data); If you prefer to stay in ereg, simply switch \w with A-Za-z0-9_ and \A and \z with ^ and $. Link to comment https://forums.phpfreaks.com/topic/91957-eregi/#findComment-470985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.