http://qs321.pair.com?node_id=803205


in reply to check for power of a number with regex

There is no "plain" regex that correctly determines whether a string's length is a square, or one that determines whether a string's length is a power of some other fixed number. The corresponding languages are not regular, and these two examples are typical examples of standard homework problems in a first theory of computation course.

Thus under your constraints, the key to such a regex must be in clever use of backreferences. But it's not clear how backrefs be useful. Backrefs can only really handle linear relations in the length of strings, while exponentiation is highly non-linear.

blokhead