What is the difference between [Regex]::Replace() and -replace?
问题 I understood the difference between .Replace() and -replace , but what are -replace and [Regex]::Replace() ? I tested the 2 following codes, but for me the results are the exactly the same. I also referred to PowerShell Cookbook(O'reilly), and it says ([Regex] is) extremely advanced regular expression replacement I want to know what [Regex] can but -replace can't. $line = "Loosen the socket by turning it#counterclockwise." $line = $line -Replace "([a-z])#([a-z])","`$1 `$2" $line # Loosen the