I have a problem about regular expressions. I wonder is it possible to evaluate a math expression on the matched result of a regular expression in powershell? I can't use powershell to evaluate it, only must regex.
Problem Statement:
I have a code something like following:
$id = $reader.GetValue(0).ToString();
$col1 = $reader.GetValue(1).ToString();
$col2 = $reader.GetValue(2).ToString();
$col3 = $reader.GetValue(3).ToString();
$col4 = $reader.GetValue(4).ToString();
$col5 = $reader.GetValue(5).ToString();
$col6 = $reader.GetValue(6).ToString();
$col7 = $reader.GetValue(7).ToString();
...
I need to increase by 3 indexes 0, 1, 2, etc. in GetValue() text with Find & Replace dialog of Powershell ISE.
Result should be like that:
$id = $reader.GetValue(3).ToString();
$col1 = $reader.GetValue(4).ToString();
$col2 = $reader.GetValue(5).ToString();
$col3 = $reader.GetValue(6).ToString();
$col4 = $reader.GetValue(7).ToString();
$col5 = $reader.GetValue(8).ToString();
$col6 = $reader.GetValue(9).ToString();
$col7 = $reader.GetValue(10).ToString();
...
I was try
Find what: GetValue\((\d)\)
Replace with: GetValue($1+3)
But I couldn't success, and I couldn't find any document or reasonable solution about the problem.
Very thanks in advance for any possible solution.