November 2017
Beginner to intermediate
204 pages
5h 23m
English
If there is a fixed number of patterns that would constitute a match, they can be combined using the following syntax:
(<pattern1>|<pattern2>|<pattern3>)
The following a_or_b regular expression will match any string where there is either an a character or a b character:
....a_or_b = re.compile("(a|b)")if a_or_b.search("a"): print("'a' is a match")if a_or_b.search("b"): print("'b' is a match")if a_or_b.search("c"): print("'c' is a match")
Read now
Unlock full access