note 71571 added to function.preg-match

From: Date: Wed, 06 Dec 2006 14:19:52 +0000
Subject: note 71571 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-120336@lists.php.net to get a copy of this message
This is a function to convert byte offsets into (UTF-8) character offsets (this is reagardless of whether you use /u modifier: <?php function mb_preg_match($ps_pattern, $ps_subject, &$pa_matches, $pn_flags = NULL, $pn_offset = 0, $ps_encoding = NULL) { // WARNING! - All this function does is to correct offsets, nothing else: // if (is_null($ps_encoding)) $ps_encoding = mb_internal_encoding(); $pn_offset = strlen(mb_substr($ps_subject, 0, $pn_offset, $ps_encoding)); $ret = preg_match($ps_pattern, $ps_subject, $pa_matches, $pn_flags, $pn_offset); if ($ret && ($pn_flags & PREG_OFFSET_CAPTURE)) foreach($pa_matches as &$ha_subpattern) $ha_subpattern[1] = mb_strlen(substr($ps_subject, 0, $ha_subpattern[1]), $ps_encoding); return $ret; } ?> ---- Server IP: 83.138.144.80 Probable Submitter: 82.152.212.233 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/71571 Del: integrated -- https://master.php.net/note/delete/71571/integrated Del: useless -- https://master.php.net/note/delete/71571/useless Del: bad code -- https://master.php.net/note/delete/71571/bad+code Del: spam -- https://master.php.net/note/delete/71571/spam Del: non-english -- https://master.php.net/note/delete/71571/non-english Del: in docs -- https://master.php.net/note/delete/71571/in+docs Del: other reasons-- https://master.php.net/note/delete/71571 Reject -- https://master.php.net/note/reject/71571 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120336) next »