#K86397. Substring Replacement
Substring Replacement
Substring Replacement
You are given a string s along with two substrings: sub1 and sub2. Your task is to replace all occurrences of sub1 in s with sub2. This operation should mimic the behavior of the typical string replace function in many programming languages.
If sub1 does not appear in s, the string should remain unchanged. Consider edge cases like empty strings and replacing with an empty substring.
The replacement must be applied to every occurrence, and the result should be printed as a single line.
inputFormat
The input is given from stdin and consists of three lines:
- The first line is the original string s.
- The second line is the substring sub1 that needs to be replaced.
- The third line is the substring sub2 that will replace each occurrence of sub1 in s.
outputFormat
Output the modified string after replacing all occurrences of sub1 with sub2. The output should be printed to stdout as a single line.
## sampleHello World
Hello
Goodbye
Goodbye World