"(" char doesn't work in PowerShell

powershell

Solution

You've got a great explanation of the exact cause of your problem from @vonPryze, but there's a much simpler solution. The `-replace` operator uses regular expressions which need escaping, but the `.Replace()` string method just uses strings. So if you don't need a regex, just use the method and there's no need to escape anything:

dir | rename-item -NewName { $_.name.Replace("(","") }

Problem

I can't get this to work. It doesn't like the "(" char; how do I fix it? ``` Dir | Rename-Item -NewName { $_.name -replace "(","" } ``` How do I handle this type of special character in PowerShell?

Original source