note 102501 added to reference.pcre.pattern.modifiers

[email protected] Thu, 17 Feb 2011 19:00:12 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Single quotes, double quotes, backslashes (\) and NULL chars will be escaped by backslashes in substituted backreferences. 
<?php
$test['test'] = 'test string to replace...';
$str = "{\$test['test']}";
$reg = '~{(\$[a-z_][\w_]*' 
  .'(?:\[[\S]+?\])*'  
  .")}~e";
$replace = '\\1';
$str = preg_replace($reg, $replace, $str);
echo $str;
?>
Fatal error:  preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: 
$test[\'test\'] 

<?php
$test['test'] = 'test string to replace...';
$str = "{\$test['test']}";
$reg = '~{(\$[a-z_][\w_]*' 
  .'(?:\[[\S]+?\])*'  
  .")}~e";
$replace = 'eval(\'return \\1;\')';
$str = preg_replace($reg, $replace, $str);
echo $str;
?>
output: test string to replace...
----
Server IP: 69.147.83.197
Probable Submitter: 59.61.166.109
----
Manual Page -- http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
Edit        -- https://master.php.net/note/edit/102501
Del: integrated  -- https://master.php.net/note/delete/102501/integrated
Del: useless     -- https://master.php.net/note/delete/102501/useless
Del: bad code    -- https://master.php.net/note/delete/102501/bad+code
Del: spam        -- https://master.php.net/note/delete/102501/spam
Del: non-english -- https://master.php.net/note/delete/102501/non-english
Del: in docs     -- https://master.php.net/note/delete/102501/in+docs
Del: other reasons-- https://master.php.net/note/delete/102501
Reject      -- https://master.php.net/note/reject/102501
Search      -- https://master.php.net/manage/user-notes.php