I understand what you posted, but unfortunately it doesn't address my problem. The actual script won't have any knowledge prior to run-time of what pattern to match, nor what the new value will be. Therefore, there is no way to know just how many $1, $2..$n variables will be used. All of this...