Guest upirate Posted April 12, 2007 Share Posted April 12, 2007 I allow my users to enter text through a text area in a variable called input $text = preg_replace("/[^a-zA-Z0-9\-\s\$\.\(\)\]\[]/i", "", $input); How can I include the newline character to be allowed in my preg_replace statement. Thanks!!! Quote Link to comment Share on other sites More sharing options...
Lumio Posted April 12, 2007 Share Posted April 12, 2007 Maybe that topic's better for the RegEx board. try to put an s to the end of the pattern $text = preg_replace("/[^a-zA-Z0-9\-\s\$\.\(\)\]\[]/is", "", $input); Quote Link to comment Share on other sites More sharing options...
Guest upirate Posted April 12, 2007 Share Posted April 12, 2007 what does the s do ? Quote Link to comment Share on other sites More sharing options...
btherl Posted April 12, 2007 Share Posted April 12, 2007 http://sg2.php.net/manual/en/reference.pcre.pattern.modifiers.php s (PCRE_DOTALL) If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines. Without it, newlines are excluded. This modifier is equivalent to Perl's /s modifier. A negative class such as [^a] always matches a newline character, independent of the setting of this modifier. Quote Link to comment Share on other sites More sharing options...
Guest upirate Posted April 12, 2007 Share Posted April 12, 2007 thankyou for the post. I just have one last question to ask you and you seem like you can: As I said before, I have this text area. I want the user to be able to cut and paste text from another site/document and for it to retain the paragraph and breaks. (but without any malicious tags etc) do you know of any place where I can find the code ? thanks again for the reply 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.