[Novalug] a regex puzzle

Jon LaBadie novalugml at jgcomp.com
Mon Mar 19 12:08:37 EDT 2012


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'
  NovaLUG

The "existing stuff" part can be a regular expression.

What would be the output of:

  echo NovaLUG | sed 's/X*/,/g'

Jon
-- 
Jon H. LaBadie                  novalugml at jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(609) 477-8330 (C)


More information about the Novalug mailing list