Slice interview question

String regex pattern to replace the strings in particular pattern