I have an exercise in formal languages, of which we work with Regex, the exercise is to validate a chain that has exactly four 1s, for example:
chain 1: 0110101000 - valid;
chain 2: 010110 - invalid;
chain 3: 011011011 - invalid;
What I've been able to do so far has been to validate a string with four or more 1s, but I have not been able to determine exactly how many times a given character should repeat:
Here is the expression that I have been able to develop so far: /(\S*1){4}.*/
This expression validates strings longer than four 1s, I need to validate a string that has exactly four 1s.
Thank you very much in advance!!