WebFund 2014W Lecture 20

From Soma-notes
Revision as of 13:59, 26 March 2014 by Soma (talk | contribs) (Created page with "Basics of Regular Expressions * start and end: / * . represents any single character * * is 0 or more repeats, + is one or more repeats * Thus .* matches any number of charact...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Basics of Regular Expressions

  • start and end: /
  • . represents any single character
  • * is 0 or more repeats, + is one or more repeats
  • Thus .* matches any number of characters (including none)
  • () denote groups, normally for extraction or later substitution
  • Each group is numbered, so first () is $1 (or something like that)
  • can include letter ranges in [], e.g. [a-z]
  • An all lowercase word with at least one character is: /[a-z]+/
  • | means or (as usual), and is implicit

Apparently there are regular expression decoders online somewhere

Escaped characters

  • \ is used to treat special characters as literals
  • % followed by hex numbers denotes character codes

Chomsky hierarchy