You are viewing a single comment's thread. Return to all comments →
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}\
When testing the string input okokokokokok against these 2 patterns, the same 2 matches are returned:
okokokokokok
Matches Returned:
- matches\[0\] okokok - matches\[1\] okokok
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\[0\] okokok - matches\[1\] ok - matches\[2\] okokok - matches\[3\] ok
Invalid Pattern Returns wrong values:
\(ok){3,}\
- matches\[0\] okokokokokok - matches\[1\] ok
Seems like cookies are disabled on this browser, please enable them to open this website
Capturing & Non-Capturing Groups
You are viewing a single comment's thread. Return to all comments →
2 Valid Patterns
The literal pattern is simply:
However, the description leaves a clue for using a non-capture group to help with this pattern.
The non-capture group pattern is:
Testing against 6 "ok" values
When testing the string input
okokokokokok
against these 2 patterns, the same 2 matches are returned:Matches Returned:
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:
Matches Returned:
Invalid Pattern Returns wrong values:
Matches Returned: