resolving the free code camp reuse-patterns-using-capture-groups problem
let repeatNum = "42 42 42";
let reRegex = /^(\d+)([" "])\1\2\1$/;
^
starts with (\d+)
a digit with at least one char (or else will count spaces) and have a([" "])
(space) after the digit and \1
to repeat the digit \2
to repeat the space \1
to repeat the digit regex again and $
to garan it will stop after encountering a char different than the digit.