Hello,
how would I do case-insensitive string replacing?
<!–StartFragment –>
`Desktop> 'aaa'.Replace('aaa', 'bbb', 'OrdinalIgnoreCase')`
`Cannot find an overload for "Replace" and the argument count: "3".`
`At line:1 char:1`
`+ 'aaa'.Replace('aaa', 'bbb', 'OrdinalIgnoreCase')`
`+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
`+ CategoryInfo : NotSpecified: (:) [], MethodException`
`+ FullyQualifiedErrorId : MethodCountCouldNotFindBest`
in C# the code works:
`foreach (string badString in badStrings)`
` fileName = fileName.Replace($".{badString}.", ".", StringComparison.OrdinalIgnoreCase);`
edit:
I found this workaround:
` foreach ($badString in $badStrings)`
` {`
` $badString = [Regex]::Escape($badString)`
` $fileName = $fileName -replace ('\.' + $badString + '\.'), '.'`
` }`