Let's say for example that I have a regular expression like this:
"The quick (red|brown|blue|yellow) fox (jumps|leaps) over the lazy (dog|cat)."
This regex has 3 grouped components - if it's matched against a given string, the regex api would allow you to easily extract the value inside each group.
Now let's say I have 3 strings:
["red", "leaps","cat"]
If we make the assumption that all the characters in the regex that are not inside groups are just literal text characters - is there a way to then insert each of those 3 strings into the corresponding group in the original regex, resulting in an output string that combines the non-grouped portion of the regex? In this case, resulting in "The quick red fox leaps over the lazy cat." Preferably, without needing to have a string that has already matched the regex.
I'm looking to do this in Java - I'm quite sure java.util.regex doesn't support this, but I thought maybe there would be a 3rd party lib out there that could allow this to be done. Can anyone give me some pointers? Thanks in advance.