I need a similar function in PHP for this.. text = text.replace(/ffc/g, "Hello"); I think preg_replace will do, but i'm not sure how to write the expression.. Thanks