From wikistone
Revision as of 22:51, 30 December 2013 by Bill (talk | contribs) (→‎Examples)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Regular expressions: the skill of the marriage of linguistics and computer logic.

RegEx Special Chars

Meta Chars

  • ^ : the beginning of a line
    • ^derp : matches 'derp flurp' but not 'flurp derp'
  • $ : the end of a line
    • derp$ : matches 'flurp derp' but not 'derp flurp'
  • . : any char (except newline)

Quantifiers

  • * : 0+ of prev char
  • + : 1+ of prev char
  •  ? : 1 of prev char

Quantifiers must be escaped in the expression with '\'.

Char Classes

  • [0-9] : numerics
  • [a-z] : lowercase
  • [A-Z] : uppers

Char classes match one char only each.

Examples

Given file.txt :

rabbit
fox
rabbit fox
fox rabbit
deer
moose
murp1
murp11
gnu3a

...add some examples