Often when using the -Replace (Operator) or .replace() (Method) in Powershell, I forget that the former parses the string in regex and in case you’re passing Special characters in the string, you’ll get the error all over your console. That is because some special characters are part of regular expression language and are considered are Meta Characters in RegEx, so it’s always a best practice to Escape special characters.
To your rescue, here is a quick tip to escape all special characters in a string using the .Net Type accelerator for Regular expression [RegEx] , something in the following image –
and an animation with a use case.
Hope you’ll find this useful, until next time, Cheers!
My new book : PowerShell Scripting Guide to Python
This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
“Use what you know to learn what you don’t. ” also known as Associative learning.
Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –
- Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
- Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.
Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data Science, Artificial Intelligence (AI) and Machine Learning Python is a must know.
But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell
NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!
While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com
Prateek Singh
Related posts
0 Comments
Leave a ReplyCancel reply
Categories
Author of Books
Awards
Open Sourced Projects
Author at
Blog Roll
Mike F RobbinsDamien Van Robaeys
Stéphane van Gulick
Kevin Marquette
Adam Bertram
Stephanos Constantinou
Francois-Xavier Cat
Ravikanth Chaganti
Roman Levchenko
Blog Stats
- 1,131,934 People Reached
[…] on April 25, 2017 submitted by /u/Prateeksingh1590 [link] [comments] Leave a […]