PowerShellRegular Expressions


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