<?php $re = '/(@)|(?!^)\G\w/'; $str = "email@xyz.com"; $subst = "$1x"; echo $result = preg_replace($re, $subst, $str);
Standard input is empty
email@xxxx.com
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!