-match

noun

say it: “MACH” /mætʃ/

A PowerShell operator that checks whether some text fits a pattern and answers True or False.

What does -match do?

-match checks whether text fits a regular expression and answers True or False. It ignores capital letters; -cmatch is the case-sensitive version. When it answers True, the text it matched is waiting in $Matches.

'paid order TM-48213' -match '\d+'   # True
'48213a' -match '^\d+


               # False

In a sentence

  • “'48213a' -match '^\d+#39; answered False, because of the letter at the end.”
  • “After -match answers True, $Matches holds the text it found.”

Level: Apprentice · More PowerShell terms at this level

Updated