Quantcast
Channel: Scripting Blog
Viewing all articles
Browse latest Browse all 2129

PowerTip: How to escape characters in a string using regular expressions

$
0
0

Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how escape characters for use in regex.

Hey, Scripting Guy! Question Is there a way to escape characters in a string automatically for use in regex?

Hey, Scripting Guy! Answer Use the [regex]::escape() method to automatically escape characters in a string so you can use them in regex.

[regex]::escape('something. in here (needs) escaping')

something\.\ in\ here\ \(needs\)\ escaping

The Doctor


Viewing all articles
Browse latest Browse all 2129

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>