Oct-27-2018, 06:45 PM
i can do this without re. i already have. i'm just wondering what all it would take to do it with re. my worry is that strings could have regular expression characters in them so they would need processing to escape those meta characters. i wonder how much code that would involve. here is what i coded:
def between(m,a,b): if 'find' not in dir(m): return False if not isinstance(a,type(m)): return False if not isinstance(b,type(m)): return False p = m.find(a) if p<0: return None p += len(a) q = m.find(b,p) if q<0: return None return m[p:q]i would like to make a version of this that works to find the last instance. that is, if A an B appear in the main string more than once, i can get the last one. or maybe a generic verion that gets the Nth instance with negative indexes to count from the end.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.