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