Okay, so, I have this pattern
^(([0-9*\/]+)\s??){7}$
By default, it's supposed to match 7 segments that can have one of these sample forms:
[0/2, *, 2, /]
The problem is, this matches:
* * 0/2 * * - incorrect* * * * * * * - correct* 0/2 * * * 2 * - correct* 0/2 0/2 - incorrectIn C# I would just use ++ on the first capture group and it would work, but Javascript has an outdated regex that's missing key functionalities.
Here's the playground to reproduce: https://regex101.com/r/Pk23dV/1
The (([0-9*\/]+)\s??){7}$ pattern is of ^((a)b?){x}$ type where the a part is obligatory and b part is optional. That is, the {7} quantifier in your regex means there must be at least seven occurrences of a char matched with the [0-9*\/] pattern, whether consecutive or sepearated with whitespace.
If you wanted to write an expression where \s is obligatory in between [0-9*\/]+ parts, you can use either
^[0-9*\/]+(?:\s[0-9*\/]+){6}$
^(?:([0-9*\/]+)(?:\s(?!$)|$)){7}$
See the regex demo 1 and regex demo 2.
Regex details
^ - start of string[0-9*\/]+(?:\s[0-9*\/]+){6} - one or more digits, / or * and then six occurrences of a whitespace and then one or more digits, / or *(?:([0-9*\/]+)(?:\s(?!$)|$)){7} - seven occurrences of one or more digits, / or * followed with either a whitespace if not at the end of string or the end of string$ - end of string.