Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Making use of the truthiness solution in Clear category for Between Markers by evrur97
def between_markers(text: str, begin: str, end: str) -> str:
"""
returns substring between two given markers
"""
# Test for missing markers and handle with a default value
begin_index = [0, text.find(begin) + len(begin)][begin in text]
end_index = [len(text), text.find(end)][end in text]
# Slice takes care of incorrect order
return text[begin_index:end_index]
Aug. 1, 2019
Comments: