Maybe a little convoluted but worth being noted just in case of:
m <- regexpr(paste0(x,collapse=""),paste0(z,collapse = ""),fixed=T)
seq(m,length.out=length(x))
The idea is to turn each vector in the text string and then found where the first string is in the second.
The match position give the starting postion, the lenght of the first vector gives how much indices we should return.
Drawback it will break with values above 9.
Edit to explain why it may fail:
> x2 <- c(3,4)
> y2 <- c(1,34,5)
> m <- regexpr(paste0(x2,collapse=""),paste0(y2,collapse = ""),fixed=T)
> seq(m,length.out=length(x))
[1] 2 3
It match two position but it should not match.