Replace all occurrences of a pattern in a text by another string

Replace all occurrences of a pattern in a text by another string - Coding Problem | K5kC