docs: def _findregex(self, reg_ex, start, end, bytealigned):
          """Find first occurrence of a compiled regular expression.
  
          Note that this doesn't support arbitrary regexes, in particular they
          must match a known length.
  
          """
          p = start
          length = len(reg_ex.pattern)
          # We grab overlapping chunks of the binary representation and
          # do an ordinary string search within that.
          increment = max(4096, length * 10)
          buffersize = increment + length
          while p < end:
              buf = self._readbin(min(buffersize, end - p), p)
              # Test using regular expressions...
              m = reg_ex.search(buf)
              if m:
                  pos = m.start()
              # pos = buf.find(targetbin)
              # if pos != -1:
                  # if bytealigned then we only accept byte aligned positions.
                  if not bytealigned or (p + pos) % 8 == 0:
                      return (p + pos,)
                  if bytealigned:
                      # Advance to just beyond the non-byte-aligned match and try again...
                      p += pos + 1
                      continue
              p += increment
              # Not found, return empty tuple
          return ()