December 11th, 2014

PowerTip: Replace Multiple Words in String with PowerShell

Doctor Scripto
Scripter

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"

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback