fork download
  1. <?php
  2.  
  3. $string = 'жышышышыдыдыжыжыжыж ы';
  4. $result = preg_replace('/(ж|ш)(ы)/', '$1[$2]', $string);
  5. echo $result;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
ж[ы]ш[ы]ш[ы]ш[ы]дыдыж[ы]ж[ы]ж[ы]ж ы