http://www.perlmonks.org?node_id=803567


in reply to check for power of a number with regex

It appears by the previous posts that the answer is no.

Thinking out loud...the solution would have to dynamically invoke the length of a submatch as a quantifier, or count its occurrences, neither of which seems to be allowed.

Or you could cheat and check for every power less than n, in a massive alternation, by building a custom regex before the match.

-QM
--
Quantum Mechanics: The dreams stuff is made of

  • Comment on Re: check for power of a number with regex