Hi, I was trying to make a regex that matches only if x is present power of 2 times (n=2). Asked otherwise, make a regex that matches if the length of the string is the power of 2 where the only character in the string is x in this case.
So for example,
xx (2), xxxx (4), xxxxxxxx (8) should match but xxx (3), xxxxxx (6) should not match.
Besides this, I also have a query on the regex I was trying to make:
to match xx, xxxx and not xxxxxx but this matches the later (see here). From the debugger also, I cannot understand why last 2 x in 6 x matches with the inner group when we have {2} outside.
So for example,
xx (2), xxxx (4), xxxxxxxx (8) should match but xxx (3), xxxxxx (6) should not match.
Besides this, I also have a query on the regex I was trying to make:
Copy Code
^((xx)*){2}$
to match xx, xxxx and not xxxxxx but this matches the later (see here). From the debugger also, I cannot understand why last 2 x in 6 x matches with the inner group when we have {2} outside.