def last_word(text, include='<STR_LIT>'):
if not text:   <EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if text[-<NUM_LIT:1>].isspace():<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>regex = cleanup_regex[include]<EOL>matches = regex.search(text)<EOL>if matches:<EOL><INDENT>return matches.group(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>
Find the last word in a sentence.
>>> last_word('abc')
'abc'
>>> last_word(' abc')
'abc'
>>> last_word('')
''
>>> last_word(' ')
''
>>> last_word('abc ')
''
>>> last_word('abc def')
'def'
>>> last_word('abc def ')
''
>>> last_word('abc def;')
''
>>> last_word('bac $def')
'def'
>>> last_word('bac $def', include='most_punctuations')
'$def'
>>> last_word('bac \def', include='most_punctuations')
'\\\\def'
>>> last_word('bac \def;', include='most_punctuations')
'\\\\def;'
>>> last_word('bac::def', include='most_punctuations')
'def'