Answer by Deadcode for Match strings whose length is a fourth power
.NET, 39 37 bytes^(?=((?>^((?<-1>x)+|x)|\1\2\2))*$){2}Try it online!Not only does this outgolf primo's amazing answer, but it runs at very close to exactly the same speed under .NET's regex...
View ArticleAnswer by Deadcode for Match strings whose length is a fourth power
ECMAScript, 41 bytes^((?=(x(x*)|)(?=(\2*)\3+$)(\2*$\4))\5){2}Try it online! - ECMAScript (SpiderMonkey)Try it online! - ECMAScript (Node.js - faster)Try it online! - .NET, in ECMAScript emulation...
View ArticleAnswer by Deadcode for Match strings whose length is a fourth power
Perl / Java / PCRE / .NET, 35 bytes((\2x|^x)+)\1(\3xx|x(?=\2$))+$|^x?$This beats primo's solution by 4 bytes while supporting the exact same set of regex engines.Try it online! - PerlTry it online! -...
View ArticleAnswer by primo for Match strings whose length is a fourth power
Perl / Java / PCRE / .NET, 39 bytesAnother SolutionThis is, in my opinion, one of the most interesting problems on the site. I need to thank deadcode for bumping it back up to the...
View ArticleAnswer by Deadcode for Match strings whose length is a fourth power
ECMAScript / Perl / Java / Python / Ruby / PCRE / .NET, 50 bytesHere is a solution that does not use conditionals, forward-declared or nested backreferences, lookbehind, balancing groups, or regex...
View ArticleAnswer by n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ for Match strings whose length is a...
Perl / Java / PCRE / .NET, 53 bytesSolution^((?=(^|(?<=^x)x|xx\2))(?=(^|\2\3))(^x|\4\3{12}xx))*$This regex is compatible with Java, Perl, PCRE and .NET flavors. This regex uses quite a range of...
View ArticleAnswer by Volatility for Match strings whose length is a fourth power
Perl / PCRE / .NET, 66 bytesThis (ir)regular expression seems to work.^((?(1)((?(2)\2((?(3)\3((?(4)\4x{24}|x{60}))|x{50}))|x{15}))|x))*$This regex is compatible with PCRE, Perl, .NET flavors.This...
View ArticleMatch strings whose length is a fourth power
Within the scope of this question, let us consider only strings which consist of the character x repeated arbitrary number of times.For example:<empty>xxxxxxxxxxxxxxxxxxx(Well, actually it...
View Article