note 67807 added to function.preg-match

From: Date: Wed, 05 Jul 2006 18:48:29 +0000
Subject: note 67807 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-114385@lists.php.net to get a copy of this message
This function (for PHP 4.3.0+) uses preg_match to return the regex position (like strpos, but using a regex pattern instead): function preg_pos($sPattern, $sSubject, &$FoundString, $iOffset = 0) { $FoundString = NULL; if (preg_match($sPattern, $sSubject, $aMatches, PREG_OFFSET_CAPTURE, $iOffset) > 0) { $FoundString = $aMatches[0][0]; return $aMatches[0][1]; } else { return FALSE; } } It also returns the actual string found using the pattern, via $FoundString. ---- Server IP: 66.163.161.117 Probable Submitter: 66.217.117.38 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- http://master.php.net/note/edit/67807 Del: integrated -- http://master.php.net/note/delete/67807/integrated Del: useless -- http://master.php.net/note/delete/67807/useless Del: bad code -- http://master.php.net/note/delete/67807/bad+code Del: spam -- http://master.php.net/note/delete/67807/spam Del: non-english -- http://master.php.net/note/delete/67807/non-english Del: in docs -- http://master.php.net/note/delete/67807/in+docs Del: other reasons-- http://master.php.net/note/delete/67807 Reject -- http://master.php.net/note/reject/67807 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114385) next »