<?php $string = 'жышышышыдыдыжыжыжыж ы';$result = preg_replace('/(ж|ш)(ы)/', '$1[$2]', $string);echo $result;
Standard input is empty
ж[ы]ш[ы]ш[ы]ш[ы]дыдыж[ы]ж[ы]ж[ы]ж ы
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!