dimanche 19 avril 2015

Extracting a substring of a string in Python based on presence of another string

common is always present regardless of string. Using that information, I'd like to grab the substring that comes just before it, in this case, "banana":



string = "apple_orange_banana_common_fruit"


In this case, fruit:



string = "fruit_common_apple_banana_orange"


How would I go about doing this in Python?


Aucun commentaire:

Enregistrer un commentaire