Regular Expression
noun
say it: “REJ-eks” /ˈrɛdʒɛks/ or “REG-yuh-ler ik-SPRESH-un” /ˈrɛɡjələr ɪkˈsprɛʃən/
A pattern that describes the shape of some text, such as letters, then a dash, then digits, used to search for or test text.
What is a regular expression in PowerShell?
A regular expression is a pattern that describes the shape of text instead of exact words. \d is any digit, + means one or more, [A-Z] is any capital letter, and ^ and $ are the start and end. -match and Select-String both take one, so [A-Z]+-\d+ finds order numbers such as TM-48213.
'paid order TM-48213' -match '[A-Z]+-\d+' # True
$Matches[0] # TM-48213
In a sentence
- “Maya built the regular expression a piece at a time, testing it with -match after each piece.”
- “The regular expression [A-Z]+-\d+ found every order number in the notes, whatever its digits.”
Level: Journeyman · More PowerShell terms at this level
Updated