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!!! Link to comment https://forums.phpfreaks.com/topic/46679-simple-question-regarding-preg_replace/ 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); Link to comment https://forums.phpfreaks.com/topic/46679-simple-question-regarding-preg_replace/#findComment-227419 Share on other sites More sharing options...
Guest upirate Posted April 12, 2007 Share Posted April 12, 2007 what does the s do ? Link to comment https://forums.phpfreaks.com/topic/46679-simple-question-regarding-preg_replace/#findComment-227420 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. Link to comment https://forums.phpfreaks.com/topic/46679-simple-question-regarding-preg_replace/#findComment-227422 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 Link to comment https://forums.phpfreaks.com/topic/46679-simple-question-regarding-preg_replace/#findComment-227423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.