#C9122. Replace All Occurrences in a Document
Replace All Occurrences in a Document
Replace All Occurrences in a Document
Given a document (a string), and two other strings S and T, your task is to replace all occurrences of S in the document with T.
Formally, if the document is denoted as $D$, you need to produce a new string $R$ such that every occurrence of $S$ in $D$ is replaced with $T$. For example, given $D = \texttt{hello world}$, $S = \texttt{world}$ and $T = \texttt{earth}$, the result will be hello earth
.
Please note that if S does not occur in the document, the document should remain unchanged.
inputFormat
The input is given from standard input (stdin) and consists of three lines:
- The first line contains the document string.
- The second line contains the string S (the substring to be replaced).
- The third line contains the string T (the substring to replace with).
Note: The document or any of the strings may be empty.
outputFormat
Output to standard output (stdout) a single line containing the modified document after replacing all occurrences of S with T.
## samplehello world
world
earth
hello earth