70 likes | 210 Views
RE review (Perl syntax). single-character disjunction: [aeiou] ranges: [0-9] negation: [^aeiou] matching zero or one: /cats?/. Conjunction. Two regular expressions are conjoined by juxtaposition (placing the expressions side by side). Examples: /a/ matches ‘a’ /m/ matches ‘m’
E N D
RE review (Perl syntax) single-character disjunction: [aeiou] ranges: [0-9] negation: [^aeiou] matching zero or one: /cats?/ CSE 467/567
Conjunction Two regular expressions are conjoined by juxtaposition (placing the expressions side by side). Examples: /a/ matches ‘a’ /m/ matches ‘m’ /am/ matches ‘am’ but not ‘a’ or ‘m’ alone CSE 467/567
The Kleene star and plus The Kleene star (*) matches zero or more occurrences of the preceding expression. Examples: /a*/ matches ‘’, ‘a’, ‘aa’, ‘aaa’, etc. /[ab]*/ matches ‘’, ‘a’, ‘b’, ‘aa’, ‘ab’, ‘ba’, ‘bb’, etc. + matches one or more occurrences CSE 467/567
Wildcard The period (.) matches any single character except the newline (\n). CSE 467/567
Anchors Anchors are used to restrict a match to a particular position within a string. ^ anchors to the start of a line $ anchors to the end of a line \b anchors to a word boundary \B anchors to a non-boundary CSE 467/567
Grouping • () group CSE 467/567
Disjunction We have already seen disjunction of characters using the square bracket notation General disjunction is expressed using the vertical bar (|), also called the pipe symbol. CSE 467/567