The answer is "by brutest possible force".<p>It does trial division on the number in base 1 representation. That is, as a string of N 1s. It takes every sub-string of the number (except 0 and 1) and sees if you can reproduce the original in an integer number of steps.<p>^(..+?) is a substring of at least 2 characters at the beginning
\1 is a copy of it
+$ is the part doing the work: look for an exact number of copies, filling up the entire string<p>The ^.?$ part is "0 and 1 don't count".<p>It's basically equivalent to a for loop from 1 to N. Divide N by the number and look for a remainder. Except that the division is done in base 1, by duplicating the string over and over and seeing it it lines up.<p>Clever, but certainly not useful.