note 46548 deleted from function.ereg by sean
| From: | sean@php.net | Date: | Fri, 15 Oct 2004 03:41:16 +0000 |
| Subject: | note 46548 deleted from function.ereg by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78569@lists.php.net to get a copy of this message | ||
Note Submitter: drenintell
----
Warning:
Using "[[:space:]]" with the eregX functions can be misleading. eregX function seem to
match more then just the old plane chr(32) (i.e. ascii space char). For example one would expect the
following code to return false:
<?php
$str= "\n";
echo (ereg("[[:space:]]", $str) ? 'True' : 'False')."\n";
?>
---------------------------------------------------
Output:
True
True would also be return if $str= "\t" or "\r". If you find any other, please
anounce them here for completeness.
If your intensions are to check for a "real" space use this:
<?php
$str= "\n";
echo (ereg("[ ]", $str) ? 'True' : 'False')."\n"; // Notice
the space between the brackets.
?>
----------------------------------------------------
Output:
False
----
Reason: bad code