LanX has asked for the wisdom of the Perl Monks concerning the following question:
the following example shows how to "ascii-draw" a tree with one regex!
That's for sure possible in a sole RegEx without while loop just with a /g-modifier!DB<83> $_="x"x30 DB<84> 1 while s/^( *x+)xx/ $1\n$&/;print "$_\n $1\n $1" xx xxxx xxxxxx xxxxxxxx xxxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xx
But how? I experimented with \G but without success..
Cheers Rolf
more golfing at Re: Christmas Tree
UPDATE: added 2 missing whitespaces
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Resetting pos() within a RegEx?
by ikegami (Patriarch) on Jan 10, 2009 at 18:33 UTC | |
|
Re: Resetting pos() within a RegEx?
by Skeeve (Parson) on Jan 10, 2009 at 21:41 UTC | |
|
Re: Resetting pos() within a RegEx?
by JavaFan (Canon) on Jan 11, 2009 at 01:06 UTC | |
by LanX (Saint) on Jan 11, 2009 at 01:55 UTC | |
by Skeeve (Parson) on Jan 11, 2009 at 09:14 UTC | |
by LanX (Saint) on Jan 11, 2009 at 17:44 UTC | |
|
Re: Resetting pos() within a RegEx?
by JavaFan (Canon) on Jan 12, 2009 at 14:02 UTC |