Regex 斐波那契文本序列的特殊性质

Regex 斐波那契文本序列的特殊性质,regex,math,Regex,Math,有人能告诉我斐波那契数/文本表示的一些特殊性质吗。更具体地说,我感兴趣的是子词或词的索引何时部分或完全匹配 比如说 w0 = a w1 = b w2 = ba w3 = **b**a**b** - 0 and 2nd index match for w3 w4 = **ba**b**ba** - here the first two and last two indexes match and so on. 换句话说,你们知道斐波那契词有什么特殊的模式匹配特性吗?或者,如果你能知道一些关于这个

有人能告诉我斐波那契数/文本表示的一些特殊性质吗。更具体地说,我感兴趣的是子词或词的索引何时部分或完全匹配

比如说

w0 = a
w1 = b
w2 = ba
w3 = **b**a**b** - 0 and 2nd index match for w3
w4 = **ba**b**ba** - here the first two and last two indexes match and so on.
换句话说,你们知道斐波那契词有什么特殊的模式匹配特性吗?或者,如果你能知道一些关于这个话题的好消息来源


谢谢,可以用于它的东西叫做“边框数组”,它是数组,在字符串的给定位置显示最长的前缀也是后缀

Algorithm Border Array Construction
Output: Border array H for string w (stored in array of char "x").
1: H[1] ← 0
2: for i ← 1..(n − 1) do
3: b ← H[i]
4: while b > 0 and x[i + 1] != x[b + 1] do
5: b ← H[b]
6: end while
7: if x[i + 1] = x[b + 1] then
8: H[i + 1] ← b + 1
9: else
10: H[i + 1] ← 0
11: end if
12: end for
例如:

  1 2 3 4 5 6 7 8 9
x a b a a b a b a ∗
H 0 0 1 1 2 3 2 3 ?

你试过哪个正则表达式?