Data Formatting
General Info
Useful Snippets

9.0.25 Return Substring between two words

Example:

def return_substring_between_two_words(text, start_word, end_word):
    '''
    Specify a 'start_word and an end_word, and this function returns the string between those two words
    '''    
    text = str(text)

    start_word_position = text.find(start_word)
    start_word_position = start_word_position + len(start_word)
    end_word_position   = text.find(end_word)
    substring           = text[start_word_position:end_word_position] # use the start and end positions to slice the string
    return(substring)