note 94110 added to function.strcspn

From: Date: Fri, 16 Oct 2009 17:55:56 +0000
Subject: note 94110 added to function.strcspn
Groups: php.notes 
Request: Send a blank email to php-notes+get-161816@lists.php.net to get a copy of this message
strcspn() can also be thought of as analogous to the following regular expression: <?php // where ... represents the mask of characters preg_match('/[^ ...]/', substr($subject, $start, $length) ); ?> By this analogy, strcspn() can be used in place of some regular expressions to match a pattern without the overhead of a regex engine -- for example, ways to verify if an input string represents a binary value: <?php preg_match('/^[01]+$/i', $subject); // or... !preg_match('/[^01]/i', $subject); // ...or using strcspn() !strcspn($subject, '01'); ?> ---- Server IP: 192.41.40.227 Probable Submitter: 67.237.228.46 ---- Manual Page -- http://www.php.net/manual/en/function.strcspn.php Edit -- https://master.php.net/note/edit/94110 Del: integrated -- https://master.php.net/note/delete/94110/integrated Del: useless -- https://master.php.net/note/delete/94110/useless Del: bad code -- https://master.php.net/note/delete/94110/bad+code Del: spam -- https://master.php.net/note/delete/94110/spam Del: non-english -- https://master.php.net/note/delete/94110/non-english Del: in docs -- https://master.php.net/note/delete/94110/in+docs Del: other reasons-- https://master.php.net/note/delete/94110 Reject -- https://master.php.net/note/reject/94110 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161816) next »