If I understand you correctly (and maybe not, see How to ask better questions using Test::More and sample data) you want this:
- Find the position of the first 'x'.
- Find the position of the second 'x'.
- Take the difference in these positions, add it to the second position and look here for the third 'x'.
- If all that succeeds you have a match.
In which case, just code this up with a loop and judicious use of index and substr.
However, this does sound rather like an XY Problem. Perhaps if you explained why you want to do this in the first place a much better solution might become apparent.