PowerTip: Replace Multiple Words in String with PowerShell

Doctor Scripto

Summary: Use Windows PowerShell to replace multiple words in a string.  

Hey, Scripting Guy! Question How can I use Windows PowerShell to replace misspelled words in a string?

Hey, Scripting Guy! Answer Use the –Replace operator, for example:

$s = "The calander says there are five calendar days left in the callander"

$s -replace "calander|callander","Calendar"

0 comments

Discussion is closed.

Feedback usabilla icon