0
0
PowerShellscripting~5 mins

Common regex patterns in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the regex pattern \d match?
It matches any single digit from 0 to 9.
Click to reveal answer
beginner
What is the purpose of the regex pattern \w+?
It matches one or more word characters (letters, digits, or underscore).
Click to reveal answer
beginner
Explain the regex pattern ^abc$.
It matches the exact string 'abc' only, from start (^) to end ($) of the line.
Click to reveal answer
beginner
What does the regex pattern \s* match?
It matches zero or more whitespace characters (spaces, tabs, newlines).
Click to reveal answer
beginner
How does the regex pattern [a-zA-Z] work?
It matches any single letter from a to z or A to Z (case sensitive).
Click to reveal answer
Which regex pattern matches a string that starts with 'cat'?
Acat$
Bcat*
C\bcat\b
D^cat
What does the regex pattern \D match?
AAny digit
BAny non-digit character
CAny whitespace
DAny word character
Which pattern matches one or more digits in a row?
A\d+
B\d*
C\d?
D\d{0}
What does [0-9a-fA-F] match?
AAny digit or letter a-f or A-F
BOnly digits 0-9
COnly letters a-f
DOnly uppercase letters
Which regex matches zero or more whitespace characters?
A\s+
B\S*
C\s*
D\s?
List and explain three common regex patterns used to match digits, words, and whitespace.
Think about shortcuts for digits, letters, and spaces.
You got /3 concepts.
    Describe how anchors like ^ and $ are used in regex patterns.
    Anchors fix where the pattern should appear in the text.
    You got /3 concepts.