I would like to generate strings that match a certain pattern. For example, the function would take two parameters:
function parsePattern(pattern, string) {}
And the accepted pattern could be '(hello|hi), %i, (how are you|nice to see you)' and if the 2nd param is set as 'John' in this way
parsePattern('(hello|hi), %i, (how are you|nice to see you)', 'John')
I would like the output to have all the possible combinations:
'hello, John, how are you'
'hello, John, nice to see you'
'hi, John, how are you'
'hi, John, nice to see you'
What's the best way to achieve this?