That's for sure possible in a sole RegEx without while loop just with a /g-modifier!No. A regexp cannot print anything. Somewhere, you need to execute code, either outside a regexy construct, in the replacement part of an s/// with the /e modifier, or by using (?{ }) or (??{ }).
But if I'm allowed to execute code, than the constraint "do it in a single regexp" isn't a constraint at all. Then I just do /^(?{ code to generate whatever you want })/.
I suggest to be more specific in what you (dis)allow to have a more fun challenge.
In reply to Re: Resetting pos() within a RegEx?
by JavaFan
in thread Resetting pos() within a RegEx?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |