while there are several steps to using regular expressions in pythoneach step is fairly simple note import the regex module with import re create regex object with the re compile(function (remember to use raw string pass the string you want to search into the regex object' search(method this returns match object call the match object' group(method to return string of the actual matched text while encourage you to enter the example code into the interactive shellyou should also make use of web-based regular expression testerswhich can show you exactly how regex matches piece of text that you enter recommend the tester at more pattern matching with regular expressions now that you know the basic steps for creating and finding regular expression objects using pythonyou're ready to try some of their more powerful pattern-matching capabilities grouping with parentheses say you want to separate the area code from the rest of the phone number adding parentheses will create groups in the regex(\ \ \ )-(\ \ \ -\ \dd\dthen you can use the group(match object method to grab the matching text from just one group the first set of parentheses in regex string will be group the second set will be group by passing the integer or to the group(match object methodyou can grab different parts of the matched text passing or nothing to the group(method will return the entire matched text enter the following into the interactive shellphonenumregex re compile( '(\ \ \ )-(\ \ \ -\ \ \ \ )'mo phonenumregex search('my number is 'mo group( ' mo group( ' - mo group( 'mo group('if you would like to retrieve all the groups at onceuse the groups(method--note the plural form for the name