Requirements
- The input consists of one string named
inputStr.
- Each pattern has a substring inside parentheses, immediately followed by a repetition count inside curly braces.
- Replace every pattern with the result of concatenating its contents the specified number of times.
- Patterns may be nested within one another, as in
(ef((ab){2}cd){2}){2}.
- Repetition counts may contain multiple digits.
- An input can include spaces. Ignore spaces that are irrelevant when the statement allows them.
Examples
Input:
(ab){3}
Output:
ababab
The group ab is repeated three times.
Input:
(a(bc){2}){2}
Output:
abcbcabcbc
The inner group produces bcbc, making the outer group abcb c without the spacing, and that complete result is repeated twice.