- 835 名前:nobodyさん mailto:sage [2011/11/24(木) 01:59:39.52 ID:???]
- >>834
入れ子の対応とりつつマッチするには Subroutine Referencesを使えば良いよ。 <?php $re = '/(?:!\[\[(?:(?!!\[\[)(?!\]\]).|(?R))*\]\])/s'; $text = "![[ 文[字]列 ![[別の文字]] ![[ほげほげ]] ]]"; $position = array(); for ($i = 0; $i < strlen($text); $i++) { $pos = strpos($text, '!', $i); if (end($position) !== $pos) $position[] = $pos; } foreach ($position as $pos) { $t = substr($text, $pos); if (($pos === 0 || $pos) && preg_match_all($re, $t, $match, PREG_SET_ORDER)) { var_dump($pos); var_dump($t); var_dump($match); print "----\n"; } } ?>
|

|