The challenge
Insert one string into another at a given index.
Given a string input in the format:
#:Pattern:Word
Where:
#
is a positive integer marking the indexPattern
is the string (whose length is undefined) to insert:
is a delimiterWord
is the string to insert into.
Assume that a :
will not be used in either string.
For example, if your input was
3:A2C:Hello World!
The output would be
HelA2Clo World!
If an invalid index is provided, the program must respond with an error. For example
12:!*!:Hello
is a valid input and must be explicitly handled somehow. For example, printing "Invalid input!" (or nothing at all!) is a valid way to catch, however crashing is not valid.
#
is a valid, positive integer. \$\endgroup\$