Partial regex

I have a regex that I'm testing a character input stream. I wonder if there is a way to match the regex to the input and determine if this is a partial match that consumes the entire input buffer? That is, the end of the input buffer will be reached before regexp completes. I would like the implementation to decide whether to wait for more character input or to abort the operation.

In other words, I need to determine which one is true:

  • The end of the input buffer was reached before regex matching

    eg. "foo" =~ /^foobar/

  • Regular expression is exactly the same as

    eg. "foobar" =~ /^foobar/

  • Regular expression does not match

    eg. "fuubar" =~ /^foobar

Entrance is not packetized.

+3
source share
2 answers

, ? , . 'Foobar'. , . 'foo', . , .

, . ,

If (input.Length < target.Length && target.StartsWith(input))
   // keep trying

, , . , , .

0

, , . , . . , .

, , , .

.

- , , ( , ). . , , .

: /(<function.*?>)|([^<]*)/ , / , 2.

, , , , .

: 64 . 10. . (64k - 10) , 10 . (64k-10) . , 10 , / 1 , .

, /, .

0

Source: https://habr.com/ru/post/1786920/


All Articles