Find and replace strings with REGEX and replacement string is incremental

Hello, I have a big file with several patterns to be replaced. Some of the strings are on the same line and I also need to increment the replacement value. At last I would like to keep in a file the “matching/original” value and “replaced” value. Any ideas how to achieve that?

Example input:

<requestId>qwerty-qwer12-qwer56</requestId>Ace of Base Order: Q2we45-Uj87f6-gh65De<something else...
<requestId>1234qw-12qw9x-123456</requestId> Stevie Wonder <messageId>1234qw-12qw9x-123456</msg

Desired output:

<requestId>Request-1</requestId>Ace of Base Order: Request-2<something else...
<requestId>Request-4</requestId> Stevie Wonder <messageId>Request-4</msg

And the code which I cannot make running is:

<requestId>qwerty-qwer12-qwer56</requestId>Ace of Base Order: Q2we45-Uj87f6-gh65De<something else…
<requestId>1234qw-12qw12-123456</requestId>kljsldjslddsdfdsdsdfff <messageId>1234qw-12qw12-123456</msg

'@ | Set-Content $log -Encoding UTF8

$requestId = @{
Count = 1
Matches = @()

$repid= [regex]::matches((Get-Content $log),’\w{6}-\w{6}-\w{6}’).value
foreach( $rep in $repid ) {
$matched = @($_ | Select-String -Pattern $rep)
if( -not $matched ) {
Get-Content $log