I want to find a regular expression in a larger string from a specific position forward and without using string fragments .
My background is that I want to do a string search iteratively for matches between different regular expressions. A natural solution in Python would be to track the current position within the string and use, for example,
re.match(regex, largeString[pos:])
in a loop. But for really large strings (~ 1 MB), string slicing, like in largeString[pos:] , becomes expensive. I am looking for a way around this.
Side note. Funny, in the niche of the Python documentation , it talks about the optional pos parameter for the matching function (which will be exactly what I want), which cannot be found using the functions themselves :-).
source share