regular expressions [' '[' '[' 'the numbers are still in list and need to be converted from strings to floating pointbut we have used the power of regular expressions to both search and extract the information we found interesting as another example of this techniqueif you look at the file there are number of lines of the formdetailsif we wanted to extract all of the revision numbers (the integer number at the end of these linesusing the same technique as abovewe could write the following programsearch for lines that start with 'detailsrev=followed by numbers then print the number if one is found import re hand open('mbox-short txt'for line in handline line rstrip( re findall('^details*rev=([ - ]+)'lineif len( print(xcodetranslating our regular expressionwe are looking for lines that start with details:followed by any number of characters *)followed by rev=and then by one or more digits we want to find lines that match the entire expression but we only want to extract the integer number at the end of the lineso we surround [ - ]with parentheses when we run the programwe get the following output[' '[' '[' '[' 'remember that the [ - ]is "greedyand it tries to make as large string of digits as possible before extracting those digits this "greedybehavior is why we get all five digits for each number the regular expression library expands in both directions until it encounters non-digitor the beginning or the end of line now we can use regular expressions to redo an exercise from earlier in the book where we were interested in the time of day of each mail message we looked for lines of the form