msaspence Posted March 27, 2007 Share Posted March 27, 2007 I'm having a problem with the ereg function to verify a user submitted variable the situation is that the user is submitting a textarea post variable there are a number of allowed characters there are more in the actual application but i have removed to demonstrate the problem as removing them makes no difference the php code is as follows $message=$_POST['textarea1']; if (ereg("^[A-Za-z0-9\n]*$",$message)) { $textValid=TRUE; } else { echo "error"; } but it seems to act like $message=$_POST['textarea1']; if (ereg("^[A-Za-z0-9]*$",$message)) { $textValid=TRUE; } else { echo "error"; } Link to comment https://forums.phpfreaks.com/topic/44548-ereg-searching-for-newline-not-acting-properly/ Share on other sites More sharing options...
hitman6003 Posted March 28, 2007 Share Posted March 28, 2007 You need to escape the backslash in your regular expression syntax.... ^[A-Za-z0-9\\n]*$ Link to comment https://forums.phpfreaks.com/topic/44548-ereg-searching-for-newline-not-acting-properly/#findComment-216512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.