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 Quote Link to comment 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"^] Quote Link to comment 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 Quote Link to comment 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 $. 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.