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.
然而,如果你认为存在重叠的可能性,则有可能采用聪明缓冲办法来完成同样的事情。
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.
例:/(<Function.*?>>(^<]
你从缓冲地带扔下/cle的那部分是第2组的缓冲。
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.
如果你能够创造便于合同/扩大的缓冲,就有更多的缓冲选择。