• + 0 comments

    2 Valid Patterns

    The literal pattern is simply:

    \okokok\
    

    However, the description leaves a clue for using a non-capture group to help with this pattern.

    The non-capture group pattern is:

    \(?:ok){3}\
    

    Testing against 6 "ok" values

    When testing the string input okokokokokok against these 2 patterns, the same 2 matches are returned:

    Matches Returned:

     - matches\[0\] okokok
     - matches\[1\] okokok
    

    Regarding Issues with other Patterns

    I noticed a few submissions that return true on matches, but they either produce the wrong number of matches or invalid match values.

    Invalid Pattern Returns 4 Matches instead of 2:

    \(ok){3}\

    Matches Returned:

     - matches\[0\] okokok
     - matches\[1\] ok
     - matches\[2\] okokok
     - matches\[3\] ok
    

    Invalid Pattern Returns wrong values:

    \(ok){3,}\

    Matches Returned:

     - matches\[0\] okokokokokok
     - matches\[1\] ok