Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
try-except with str.index to find endpoints solution in Clear category for Between Markers by rossras
def between_markers(text: str, begin: str, end: str) -> str:
"""
returns substring between two given markers
"""
try:
start_index = text.index(begin) + len(begin)
except ValueError:
start_index = 0
try:
end_index = text.index(end)
except ValueError:
end_index = len(text)
return text[start_index:end_index]
Feb. 2, 2020
Comments: