preg_split について
- [PHP-users 24880] preg_splitについて
http://ns1.php.gr.jp/pipermail/php-users/2005-March/025400.html
<?php
/*
* 前方に`\' が無い `,' で分割したい
*/
$dat = 'ab,cd,ef\,gh';
// OK
$dats = preg_split('/(?<!\x5C),/', $dat);
$dats = preg_split('/(?<!\\\\),/', $dat);
$dats = preg_split("/(?<!\\\\),/", $dat);
// NG - `Compilation failed: missing ) at offset'
$dats = preg_split('/(?<!\\),/', $dat);
$dats = preg_split("/(?<!\\),/", $dat);
print_r($dats); // 期待値: Array([0] => ab [1] => cd [2] => ef\,gh)
?>