and :\ *([-\ ]+)only one of which can match the first of these matches an equals sign followed by one or more word or hyphen characters (optionally enclosed in matching quotes using conditional match)and the second matches colon and then optional whitespace followed by one or more word or hyphen characters (recall that hyphen inside character class is taken to be literal hyphen if it is the first characterotherwiseit means range of charactersfor example[ - we have used the re ignorecase flag to avoid having to write (?:(?:[ee][nn])[cc][oo][dd][ii][nn][gg]|[cc][hh][aa][rr][ss][ee][tt]and we have used the re verbose flag so that we can lay out the regex neatly and include comments (in this case just numbers to make the parts easy to refer to in this textthere are three capturing match groupsall in the third part(["'])which captures the optional opening quote([-\ ]+which captures an encoding that follows an equals signand the second ([-\ ]+(on the following linethat captures an encoding that follows colon we are only interested in the encodingso we want to retrieve either the second or third capture grouponly one of which can match since they are alternatives the lastindex attribute holds the index of the last matching capture group (either or when match occurs in this example)so we retrieve whichever matchedor use default encoding if no match was made we have now seen all of the most frequently used re module functionality in actionso we will conclude this section by mentioning one last function the re split(function (or the regex object' split(methodcan split strings based on regex one common requirement is to split text on whitespace to get list of words this can be done using re split( "\ +"textwhich returns list of words (or more precisely list of stringseach of which matches \ +regular expressions are very powerful and usefuland once they are learnedit is easy to see all text problems as requiring regex solution but sometimes using string methods is both sufficient and more appropriate for examplewe can just as easily split on whitespace by using text split(since the str split(method' default behavior (or with first argument of noneis to split on \ssummary ||regular expressions offer powerful way of searching texts for strings that match particular patternand for replacing such strings with other strings which themselves can depend on what was matched in this we saw that most characters are matched literally and are implicitly quantified by { we also learned how to specify character classes--sets of characters to match--and how to negate such sets and include