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 Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/ Share on other sites More sharing options...
DanyalSakrani Posted June 27, 2007 Author Share Posted June 27, 2007 Anyone? ??? ??? Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/#findComment-284375 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 } Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/#findComment-284376 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. Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/#findComment-284386 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 = '/[!|@|#|$|%|^|&|*|\(|\)]/'; Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/#findComment-284431 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. Link to comment https://forums.phpfreaks.com/topic/57475-eregi-help/#findComment-284556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.