Given two regular expressions of bit strings $B_1$ and $B_2$ of the same length (stated mathematically, $B_1,B_2 \in \{0,1\}^m$) that use only grouping and repetition, what is the optimal running time of performing a bitwise AND operation on $B_1$ and $B_2$?
For example, given two regular expressions, $B_1 = ((10)^2(01)^2)^2$ and $B_2 = (01)^8$, the resulting pattern $R$ of the AND operation would be $R = ((0^4(01)^2)^2$.
Does there exist an algorithm that will run in polynomial time (with respect to the lengths of the regular expressions)? Note, you can pair every possible combination of groups in $O(n^2)$ time, where $n$ = $\max(|B_1|,|B_2|)$, and $|B_i|$ is the length of regex $B_i$. However, that still does not give you the resulting bit string regular expression $R$.
The exponent $k$ of a given substring can be stored in binary form, so it only adds $\log(k)$ bits to the representation. Furthermore, note that given any two groups of size $m$ and $n$, there are at most $\max(m,n)$ bit patterns of length $\min(m,n)$ that can result. In addition, if there are $g_1$ groups in $B_1$ and $g_2$ groups in $B_2$, then there can only be $g_1 g_2$ unique pairs of groups. Therefore, I think it can be concluded that the space required is at most $O(g_1 g_2 \max(|group_{i,B_1}|,|group_{j,B_2}|)^2)$, which is polynomial in $n$. However, I am still missing the proof that the resulting regular expression can be found in polynomial time.
For slightly easier problem, you can assume that every repetition is a power of two. However, that does not necessarily mean that groups are power of two in size. For an even further simplification you, could assume the groups are also a power of two in size.
Now that I think of it, I will include this idea which I just came up with. You can represent the offsets of the 1s every group as set of linear integer equations. Then you may be able to find solutions to pairs of integer equations with constraints somehow? Or am I over complicating it?
Another possibility is, as Yuval Filmus suggests, convert to NFA. However, I am not clear why an NFA would be needed since these are fixed sequences (that is, the number of repetitions is fixed). Furthermore, I am not sure how one would apply the AND operation after they are in NFA form.