PowerShell Regular Expressions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • 'text' -match 'RegExPattern'
  • 'text' -replace 'RegExPattern', 'newvalue'
  • [regex]::Match("text","pattern") #Single match
  • [regex]::Matches("text","pattern") #Multiple matches
  • [regex]::Replace("text","pattern","newvalue")
  • [regex]::Replace("text","pattern", {param($m) }) #MatchEvaluator
  • [regex]::Escape("input") #Escape special characters


Got any PowerShell Question?