'batmanmo batregex search('the adventures of batwoman'mo group('batwomanthe (wo)part of the regular expression means that the pattern wo is an optional group the regex will match text that has zero instances or one instance of wo in it this is why the regex matches both 'batwomanand 'batmanusing the earlier phone number exampleyou can make the regex look for phone numbers that do or do not have an area code enter the following into the interactive shellphoneregex re compile( '(\ \ \ -)?\ \ \ -\ \ \ \ 'mo phoneregex search('my number is 'mo group('mo phoneregex search('my number is - 'mo group(' - you can think of the as saying"match zero or one of the group preceding this question mark if you need to match an actual question mark characterescape it with \matching zero or more with the star the (called the star or asteriskmeans "match zero or more"--the group that precedes the star can occur any number of times in the text it can be completely absent or repeated over and over again let' look at the batman example again batregex re compile( 'bat(wo)*man'mo batregex search('the adventures of batman'mo group('batmanmo batregex search('the adventures of batwoman'mo group('batwomanmo batregex search('the adventures of batwowowowoman'mo group('batwowowowomanfor 'batman'the (wo)part of the regex matches zero instances of wo in the stringfor 'batwoman'the (wo)matches one instance of woand for 'batwowowowoman'(wo)matches four instances of wo if you need to match an actual star characterprefix the star in the regular expression with backslash\pattern matching with regular expressions