Get all words or characters between two characters python

text_in_between = string.split(first_word)[1].split(second_word)[0]

Full example:

string = "Once upon a time"
first_word = "Once"
second_word = "time"
text_in_between = string.split(first_word)[1].split(second_word)[0]
print(text_in_between)
SNAPPED!

SNAPPED!

Comments

Popular posts from this blog

Append to a json file python

Setup Mailhog mail server on Ubuntu