I'm not sure if this is your question but.
Regular expressions either match or not. And the expression will match a variable amount of input. So, it can't be determined directly.
However, it is possible, if you believe there is a possibility of overlap, to use a smart buffering scheme to accomplish the same thing.
There are many ways to do this.
One way is to match all that does not match via assertions, up until you get the start
of a match (but not the full match you seek).
These you simple throw away and clear from your buffer. When you get a match you seek, clear the buffer of that data and data before it.
Example: /(<function.*?>)|([^<]*)/
The part you throw away/clear from the buffer is in group 2 capture buffer.
Another way is if you are matching finite length strings, if you don't match anything in
the buffer, you can safely throw away all from the beginning of the buffer to the end of the buffer minus the length of the finite string you are searching for.
Example: Your buffer is 64k in size. You are searching for a string of length 10. It was not found in the buffer. You can safely clear (64k - 10) bytes, retaining the last 10 bytes. Then append (64k-10) bytes to the end of the buffer. Of course you only need a buffer of size 10 bytes, constantly removing/adding 1 character but a larger buffer is more
efficient and you could use thresholds to reload more data.
If you can create a buffer that easily contracts/expands, more buffering options are available.