February 2019
Intermediate to advanced
626 pages
15h 51m
English
The hyphen is used to define a range of characters. For example, we might want to match any number that's repeated one or more times in a set (using +):
'1st place' -match '[0-9]+' # $matches[0] is "1" '23rd place' -match '[0-9]+' # $matches[0] is "23"
A range in a character class can be any range of ASCII characters, such as the following examples:
The following code returns true, as " is ASCII character 34, and # is ASCII character 35; that is, they're within the specified !-9 range:
PS> '"#' -match '[!-9]+'; $matches[0]True"#
The range notation allows hexadecimal numbers within strings to be identified. A hexadecimal character can be identified by a character class ...
Read now
Unlock full access