how to replace powershell text?

how to replace powershell text?
I want to write a script that get a string as an input:
PS C:\curl> $response.Content.Split(',') |Select-String -Pattern "dictionary_url_rus"


and replace "183011410_rus.json" with new paramter (file name that I read from file name:

$controlFileArray = Get-ChildItem $fromDir\*_rus.xml
echo $controlFileArray
Benny CaspiIntegrationAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

$newfile = "NotTheRus.json"
$dict = ($response.Content.Split(',') |Select-String -Pattern "dictionary_url_rus")
$dict -match "^(.+/)([^$]+)$" > null
$matches[2] = $newfile+'"'
$matches[1..2] - join ""

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Or this:
$newfile = "NotTheRus.json"
$dict = ($response.Content.Split(',') |Select-String -Pattern "dictionary_url_rus")
$dict -replace "^(.+/)([^$]+)$", ('$1'+$newfile+'"')

Open in new window

Unclear whether the ending quote needs preserving.
Benny CaspiIntegrationAuthor Commented:
I get next error when I run this script:
parsing "$1201804151047_rus.xml"" - Capture group numbers must be less than or equal to Int32.MaxValue.
At line:1 char:1
+ $dict -replace "^(.+/)([^$]+)$", ('$1'+$newfile+'"')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException
Remove the quote character I added to the end of the replace operation.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.