http://qs321.pair.com?node_id=1176776


in reply to Regular Expression: search two times for the same number of any signs

If I understand you correctly (and maybe not, see How to ask better questions using Test::More and sample data) you want this:

  1. Find the position of the first 'x'.
  2. Find the position of the second 'x'.
  3. Take the difference in these positions, add it to the second position and look here for the third 'x'.
  4. 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.