note 100729 added to function.preg-split

From: Date: Wed, 03 Nov 2010 11:46:49 +0000
Subject: note 100729 added to function.preg-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-173705@lists.php.net to get a copy of this message
If you want to split by a char, but want to ignore that char in case it is escaped, use a lookbehind assertion. In this example a string will be split by ":" but "\:" will be ignored: $string='a:b:c\:d'; $array=preg_split('#(?<!\\\)\:#',$string); print_r($array); Results into: Array ( [0] => a [1] => b [2] => c\:d ) ---- Server IP: 212.124.37.9 Probable Submitter: 80.153.169.158 ---- Manual Page -- http://www.php.net/manual/en/function.preg-split.php Edit -- https://master.php.net/note/edit/100729 Del: integrated -- https://master.php.net/note/delete/100729/integrated Del: useless -- https://master.php.net/note/delete/100729/useless Del: bad code -- https://master.php.net/note/delete/100729/bad+code Del: spam -- https://master.php.net/note/delete/100729/spam Del: non-english -- https://master.php.net/note/delete/100729/non-english Del: in docs -- https://master.php.net/note/delete/100729/in+docs Del: other reasons-- https://master.php.net/note/delete/100729 Reject -- https://master.php.net/note/reject/100729 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173705) next »