DanyalSakrani Posted June 27, 2007 Share Posted June 27, 2007 Hello, I would like to disable the following characters: "!@#$%^&*()", but I am not very good with eregi, can anyone show me? Thank you, Danyal Quote Link to comment Share on other sites More sharing options...
DanyalSakrani Posted June 27, 2007 Author Share Posted June 27, 2007 Anyone? ??? ??? Quote Link to comment Share on other sites More sharing options...
corbin Posted June 27, 2007 Share Posted June 27, 2007 Ummm the ereg format would look something like this: $pattern = '/!|@|#|$|%|^|&|*|\(|\)/' There has to be a better, more effecient, way to do that though.... If you're trying to block everything besides a-z A-Z 0-9 and spaces I would suggest something like: $pattern = "/[^a-z0-9 ]/i"; if(preg_match($pattern, $input)) { //got invalid stuff } Quote Link to comment Share on other sites More sharing options...
DanyalSakrani Posted June 27, 2007 Author Share Posted June 27, 2007 Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 14 in /home/.keerokee/Removed. on line 31 EEK >_<. Line 31 is your line, btw. Quote Link to comment Share on other sites More sharing options...
corbin Posted June 27, 2007 Share Posted June 27, 2007 Ahhh my bad... I'm still bad at regexp's ;p. It needed to be: $pattern = '/[!|@|#|$|%|^|&|*|\(|\)]/'; Quote Link to comment Share on other sites More sharing options...
effigy Posted June 28, 2007 Share Posted June 28, 2007 Pipes are no longer metacharacters inside of character classes; they are not needed. 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.