Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Regular Expression

N@N
September 21, 2013

Introduction to Regular Expression

姫路IT系勉強会 Vol.20で発表した内容に加筆・修正を加えたものです.

N@N

September 21, 2013
Tweet

More Decks by N@N

Other Decks in Technology

Transcript

  1. • • '[0123456789]' = '[0-9]' • '[ABCDE...Z]' = '[A-Z]' •

    '[abcde...z]' = '[a-z]' • '[012...9ABCDEFabcdef]' = '[0-9A-Fa-f]' • • [Ss]mith' blacksmith
  2. • | • • 'gr[ae]y' = 'gr(a|e)y' = 'gray|grey' •

    'gra|ey' gra ey • '[a|e]' a | e
  3. • • • $ egrep -i 'from|to' file = $

    egrep '[Ff][Rr][Oo][Mm]|[Tt][Oo]' file
  4. • + • • * • • 'A+' = 'AA*'

    • 'AA*' ≠ '(AA)*'
  5. $ find . -type f -print0 | xargs -0 sed

    -i -e 's/foo/bar/g' $ git grep -l 'foo' | xargs -0 sed -i -e 's/foo/bar/g' $ git ls-files -z | xargs -0 sed -i -e 's/foo/bar/g'