“This line has omitted .” $nested = 'on [OMIT]this line, [OMIT]you have[/OMIT] to [/OMIT]count'; #==> “on count” $multi = "this [OMIT] line\ndoesn't have [/OMIT]omissions"; #==> “this [OMIT] line\ndoesn't have [/OMIT]omissions” #begin_omit $lines = array( 'single', 'nested', 'multi' ); #end_omit ### Single-line exclusion. ### $single_pat = '@\\[OMIT\\](.*?)\\[/OMIT\\]@i'; $nested_pat = '@\\[OMIT\\]((?:(?R)|.)*?)\\[/OMIT\\]@i'; $multi_pat = '@\\[OMIT\\]((?:(?R)|.)*?)\\[/OMIT\\]@is'; $pats = array( 'single_pat', 'nested_pat', 'multi_pat', ); foreach ($pats as $pv) foreach ($lines as $lv) if ($show_borken or $pv == $lv . '_pat') printf("---%s[%s]---\n%s\n↓\n%s\n\n", $lv, $pv, $$lv, preg_replace($$pv, '', $$lv)); #end_omit ### C-like preprocessor. ### $pp_pat = <<