Regular expression, compute something like CRC in it with checks

I have an array of bytes, I need to check whether it starts with a certain number 0, ends with 9, and there can be any numbers between them, but after 9 I get the sum of numbers.

e.g test[] = { 0, 1, 4, 5, 9, 10 };
test[] = { 0, 3, 2, 9, 6, 0, 4, 2, 9, 6 }; - in this there are two sets

Is there a way to use regex to find this?

+3
source share
1 answer

This is not like ordinary language for me, so the answer is no, you cannot do it.

If the size of the list was corrected or you needed a sum of numbers modulo 10, for example, it would be very difficult, but probably doable. In the general case, the language in which words consist of a list of numbers and their sum is not regular, since it trivially does not satisfy the lemma.

.

+5

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


All Articles