note 50484 added to function.eregi-replace
| From: | joltmans at amersel dot com | Date: | Tue, 01 Mar 2005 19:06:26 +0000 |
| Subject: | note 50484 added to function.eregi-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85744@lists.php.net to get a copy of this message | ||
PHP's Regex engine differs from several others in its treatment of parsing spaces.
In many Regex languages '\s' denotes a space.
PHP does not recognize '\s', just type a space ' ' instead.
This simple example illustrates the problem:
<?php
$string = "A sentence with spaces";
if (eregi("with\s*spaces", $string))
{
// Will never print
echo "PHP understood \s";
}
else
{
// Will always print
echo "PHP doesn't understand \s";
}
?>
This example does work:
<?php
$string = "A sentence with spaces";
if (eregi("with *spaces", $string))
{
// Will print
echo "PHP understood ' '";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.eregi-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50484
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50484&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50484&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50484&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50484&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50484&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50484&report=yes
Search -- http://master.php.net/manage/user-notes.php