Oct-27-2018, 12:01 AM
i am looking for an existing function or i will code my own. given a main string and two substrings A and B ... if A and B are both in the main string and B is found after the end of A, return the substring found between A and B. if B is immediately after A then return an empty string. a way to also do this with byte strings is a big plus, even if it is a different function name. note that A and B can be strings longer than a single character and that A and B may be the same or may be different.
m = 'happy birthday to you' a = 'happy ' b = ' to' betweenstr(m,a,b) -> 'birthday' a = 'b' b = 'y' betweenstr(m,a,b) -> 'irthda' a = 'birth' b = 'day' betweenstr(m,a,b) -> '' a = 'day' b = 'happy' betweenstr(m,a,b) -> None or an exceptioni am not asking anyone to code this for me; i can do that. i am only interested in something in the Python library or i code on my own, not somehing to be installed.