fork(1) download
  1. <?php
  2.  
  3. $file = '[STRING_****] (STRING_*****) /STRING';
  4.  
  5. $searchContext = 'STRING';
  6. $replaceContext = 'NEW_STRING';
  7.  
  8. $pattern = '/([\[(\s])('.$searchContext.')/';
  9.  
  10. $result = preg_replace($pattern, "$1" . $replaceContext, $file);
  11. echo $result;
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
[NEW_STRING_****]  (NEW_STRING_*****)  /STRING