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 socket by turning it counterclockwise.
$line.GetType()
# IsPublic IsSerial Name BaseType
# -------- -------- ---- --------
# True True String System.Object
$line2 = "Loosen the socket by turning it#counterclockwise."
$line2 = [Regex]::Replace($line3,"([a-z])#([a-z])","`$1 `$2")
$line2
# Loosen the socket by turning it counterclockwise.
$line2.GetType()
# IsPublic IsSerial Name BaseType
# -------- -------- ---- --------
# True True String System.Object