User:Selena Savic/TechdazeNotes

From XPUB & Lens-Based wiki

IMPERATIVE LANGUAGES

Python

DECLARATIVE LANGUAGES

CSS

Regular expressions - finite state machine
uses:

  • SEARCH (=check for matches)
  • FINDALL (=extract; returns a list of matches)
  • SUB / FIND AND REPLACE (=automatic markup)
  • SPLIT (=cut up)

special characters:

  • [ ] - character class; either, or

0123456789 = any digit, from 0 to 9 = 0-9
a-z = any letter
? = 0, 1
+ = 1>

  • = 0>

. = any character (like star in command line)
{ } = n, m; modifiers (expanding patterns)
( ) = grouping
\d = digit
\w = word
\D = non-digit
\W = non-word
\n = new line
\s = space, any number of white spaces
\S = non-space
\b = word boundary
\0 = the match
1, $, \b = anchors

python: >>> print "hello"
hello
>>> print "h\ello"
h\ello
>>> print "h\tello" #\t stands for "tab"
h ello
>>> print "h\nello"
h
ello
>>> print r"h\nello" # r stands for "raw"
h\nello