note 46548 added to function.ereg

From: Date: Fri, 15 Oct 2004 02:59:26 +0000
Subject: note 46548 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-78567@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46548 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46548&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46548&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78567) next »