- Boolean "or"
- A vertical bar separates alternatives. For example,
gray|greycan match "gray" or "grey". - Grouping
- Parentheses are used to define the scope and precedence of the operators (among other uses). For example,
gray|greyandgr(a|e)yare equivalent patterns which both describe the set of "gray" and "grey". - Quantification
- A quantifier after a token (such as a character) or group specifies how often that preceding element is allowed to occur. The most common quantifiers are the question mark
?, the asterisk*(derived from the Kleene star), and the plus sign+(Kleene cross).
?The question mark indicates there is zero or one of the preceding element. For example, colou?rmatches both "color" and "colour".*The asterisk indicates there are zero or more of the preceding element. For example, ab*cmatches "ac", "abc", "abbc", "abbbc", and so on.+The plus sign indicates that there is one or more of the preceding element. For example, ab+cmatches "abc", "abbc", "abbbc", and so on, but not "ac".
end
No comments:
Post a Comment