TL; DR; (?<=[^x]|^)(x{n}|x{m})(?:[^x]|$)
It looks like you want to "xn times" or "xm times", I think the literal translation in regex will be (x{n}|x{m}). Like https://regex101.com/r/vH7yL5/1
or, in case you can have a sequence greater than m "x" s (assuming m> n), you can add 'follow no "x"' and 'follow after no "x", translating to [^x](x{n}|x{m})[^x] , but this assumes that there is always a character and "x" after you. As you can see here: https://regex101.com/r/bB2vH2/1
you can change it to (?:[^x]|^)(x{n}|x{m})(?:[^x]|$) by translating to "follow no" x "or after the beginning of the line" and "followed by" x "or followed by the end of the line." But still, it will not correspond to two sequences with one symbol between them (because for the first match you will need a symbol after, and the second - a symbol earlier), as you can see here: <a2>
Finally, to match one character deletion, you can add a positive look ahead (? =) To no x after or a positive look (? <=) To no x 'before, for example: https: / /regex101.com/r/mC4uX3/1
(?<=[^x]|^)(x{n}|x{m})(?:[^x]|$)
This way you will only match the exact number "x you want".
Enhardened Jul 07 '16 at 16:03 2016-07-07 16:03
source share