By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Regular expression - replace non printable chars with spaces

P: n/a
I've created a form asking a user to enter a text; the user can press
[enter] key or any other "strange" non printable char that i want to strip
away from the entred text and replace it with a " " (whitespace).
I've prepared a line with preg_preplace function but it seem doesn't work.

By the way:

$oggetto = preg_replace("(\0-\037)|(\0177-\0377)", "\040",
$_POST['oggetto']);

The result is:

Warning: No ending matching delimiter ')' found in
E:\WWWTest\biblio\newdoc.php on line 44

Any suggestion?

Thanks everyone!
Francesco
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Francesco" <fpiraneo(nospam)@libero.it> wrote:
(whitespace). I've prepared a line with preg_preplace function but it
seem doesn't work.

$oggetto = preg_replace("(\0-\037)|(\0177-\0377)", "\040",
$_POST['oggetto']);

The result is:

Warning: No ending matching delimiter ')' found in
E:\WWWTest\biblio\newdoc.php on line 44


<quote>
The syntax for patterns used in these functions closely resembles Perl.
The expression should be enclosed in the delimiters, a forward slash (/),
for example. Any character can be used for delimiter as long as it's not
alphanumeric or backslash (\). If the delimiter character has to be used
in the expression itself, it needs to be escaped by backslash. Since PHP
4.0.4, you can also use Perl-style (), {}, [], and <> matching delimiters.
</quote>
http://uk.php.net/manual/en/ref.pcre.php

HTH;
JOn
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.