we've seen many of the most basic patternsbut the regular expression language supports many more spent my first few years using regular expressions looking up the syntax every time needed to do something it is worth bookmarking python' documentation for the re module and reviewing it frequently there are very few things that regular expressions cannot matchand they should be the first tool you reach for when parsing strings getting information from regular expressions let' now focus on the python side of things the regular expression syntax is the furthest thing from object-oriented programming howeverpython' re module provides an object-oriented interface to enter the regular expression engine we've been checking whether the re match function returns valid object or not if pattern does not matchthat function returns none if it does matchhoweverit returns useful object that we can introspect for information about the pattern so farour regular expressions have answered questions such as "does this string match this pattern?matching patterns is usefulbut in many casesa more interesting question is"if this string matches this patternwhat is the value of relevant substring?if you use groups to identify parts of the pattern that you want to reference lateryou can get them out of the match return value as illustrated in the next examplepattern "^[ -za- ]+@([ - ]*[ - ]+)$search_string "some user@example commatch re match(patternsearch_stringif matchdomain match groups()[ print(domainthe specification describing valid -mail addresses is extremely complicatedand the regular expression that accurately matches all possibilities is obscenely long so we cheated and made simple regular expression that matches some common -mail addressesthe point is that we want to access the domain name (after the signso we can connect to that address this is done easily by wrapping that part of the pattern in parenthesis and calling the groups(method on the object returned by match the groups method returns tuple of all the groups matched inside the patternwhich you can index to access specific value the groups are ordered from left to right howeverbear in mind that groups can be nestedmeaning you can have one or more groups inside another group in this casethe groups are returned in the order of their left-most bracketsso the outermost group will be returned before its inner matching groups