find all datesbut print in different format monthnames [none,'jan','feb','mar','apr','may','jun''jul','aug','sep','oct','nov','dec'for in datepat finditer(text)print ("% % % (monthnames[int( group( )] group( ) group( ))replace all dates with fields in the european format (day/month/yeardef fix_date( )return "% /% /% ( group( ), group( ), group( )newtext datepat sub(fix_datetextan alternative replacement newtext datepat sub( '\ /\ /\ 'textnotes detailed information about the theory and implementation of regular expressions can be found in textbooks on compiler construction the book mastering regular expressions by jeffrey friedl ( 'reilly associates may also be useful the most difficult part of using the re module is writing the regular expression patterns for writing patternsconsider using tool such as kodos ( string the string module contains number of useful constants and functions for manipulating strings it also contains classes for implementing new string formatters constants the following constants define various sets of characters that may be useful in various string processing operations constant description ascii_letters ascii_lowercase ascii_uppercase digits hexdigits letters lowercase string containing all lowercase and uppercase ascii letters the string 'abcdefghijklmnopqrstuvwxyzthe string 'abcdefghijklmnopqrstuvwxyzthe string ' the string ' abcdefabcdefconcatenation of lowercase and uppercase string containing all lowercase letters specific to the current locale setting the string ' string of ascii punctuation characters string of printable characters-- combination of lettersdigitspunctuationand whitespace string containing all uppercase letters specific to the current locale setting string containing all whitespace characters this usually includes spacetablinefeedreturnformfeedand vertical tab octdigits punctuation printable uppercase whitespace lib fl ff