I want to do a string substitution where if I find a string between two terms I replace it, so when I have a string like:
"123 pre 456 post"
I can get:
"123 pre 789 post"
I can do this by doing something like:
However, I'd like to avoid using the two captures if possible. In fact, I'd like to use a regular expression like this instead:
/pre\s+(\S+)\s+post/ and get the range of the capture and then replace it. Is there a way to do that (using the standard Ruby libraries)?