October 2017
Intermediate to advanced
440 pages
11h 47m
English
+ and * are two of a set of characters known as quantifiers. Quantifiers are discussed in great detail later in this chapter.
The * character can be used to repeat the preceding character zero or more times, for example:
'aaabc' -match 'a*'# Returns true, matches 'aaa'
However, zero or more means the character in question doesn't have to be present at all:
'bcd' -match 'a*' # Returns true, matches nothing
If a character must be present in a string, the + quantifier is more appropriate:
'aaabc' -match 'a+'# Returns true, matches 'aaa' 'bcd' -match 'a+' # Returns false
Combining * or + with . produces two very simple expressions: .* and .+. These expressions may be used as follows:
'Anything' -match '.*' # 0 or more. ...
Read now
Unlock full access