[Novalug] a regex puzzle
daniel at yacg.com
Mon Mar 19 13:47:58 EDT 2012
I see what it does. Not going to spoil it for anyone who wants to try
it themselves. I'd like to know why.
To help myself understand better I altered the line to read:
$ echo NovaLUG | sed 's/L*/,/g'
and then again to:
$ echo NovaLUG | sed 's/LUG*/,/g'
The results are interesting.
On 03/19/2012 12:08 PM, Jon LaBadie wrote:
> The recent discussions of pattern matching and regular
> expressions brought to mind a favorite puzzle.
> Sed can be used to modify strings with its substitute
> command, eg s/existing stuff/new stuff/g. The "g" at
> the end allows sed to change all occurances rather than
> just the first.
> For example:
> $ echo Novalug | sed 's/lug/LUG'
> The "existing stuff" part can be a regular expression.
> What would be the output of:
> echo NovaLUG | sed 's/X*/,/g'
More information about the Novalug