PREFACE, Schemes and Mind Maps of English Literature

Consider if the first edition of Don't Shoot the Dog! had instead been called Practical Use of Positive Reinforcement in Human Behavioral Interaction.

Typology: Schemes and Mind Maps

2021/2022

Uploaded on 07/04/2022

Kristien_123
Kristien_123 🇳🇱

3.3

(3)

182 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Regular Expressions cheat sheet
Basic matching
Each symbol matches a single character:
.anything1
\d digit in 0123456789
\D non-digit
\w “word” (letters and digits and _)
\W non-word
space
\t tab
\r return
\n new line2
\s whitespace (␣, \t,\r,\n)
\S non-whitespace
Character classes
Character classes [...] match any of the charac-
ters in the class. Ex: [aeiou] matches vowels.
Use ˆto specify the complement set: [ˆaeiou]
matches non-vowels (including non-letters!).
Use -to specify a range of letters:
[a-e] matches abcde and [0-9a-f] matches
‘0123456789abcdef‘.
Boundaries
Boundary characters are helpful in “anchor-
ing” your pattern to some edge, but do not
select any characters themselves.
\b word boundaries (defined as any edge
between a \w and \W)
\B non-word-boundaries
ˆthe beginning of the line
$the end of the line
Ex: \bcat \b finds a match in “the cat in the hat”
but not in “locate”.
Disjunction
(X|Y) X or Y
Ex: \b(cat|dog)s\b matches cats and dogs.
“Quantifiers”
X* 0 or more repetitions of X
X+ 1 or more repetitions of X
X? 0 or 1 instances of X
X{m}exactly minstances of X
X{m,} at least minstances of X
X{m,n}between mand n(inclusive) in-
stances of X
By default, quantifiers just apply to the one
character. Use (...)to specify explicit quanti-
fier “scope.”
Ex: ab+ matches ab,abb,abbb,abbbb...
(ab)+ matches ab,abab,ababab...
Quantifiers are by default greedy in regex.
Good regex engines support adding ?to a
quantifier to make it lazy.
Ex: greedy: ^.*b aabaaba
lazy: ^.*?b aabaaba
Special characters
The characters {}[]()^$.|*+?\ (and -inside
[...]) have special meaning in regex, so they
must be “escaped” with \to match them.
Ex: \. matches the period .and \\ matches the
backslash \.
Backreferences
Count your open parentheses (from the left,
starting with 1. Whatever is matched byparen-
thesis number ncan be referenced later by \n.
Ex: \b(\w+)\1\b matches two identical words
with a space in between
Backreferences are useful for find/replaces:
Ex: Finding \b (\w +)er\b and replacing with
more \1 will map “the taller man” 7→ “the
more tall man” and “I am shorter” 7→ “I am
more short”.
Advanced
Read about “non-capturing parentheses” and
“look-ahead” and “look-behind” online. Also,
visualize your regexes as finite-state machines
at http://www.regexper.com/.
1...except line breaks, depending on your engine.
2Depending on where you got your file, line breaks may be \r,\n, or \r\n. Also, in some regex engines
(e.g. TextWrangler), \r and \n match the same things.
Hadas Kotek (courtesy of Michael Y. Erlewine)

Partial preview of the text

Download PREFACE and more Schemes and Mind Maps English Literature in PDF only on Docsity!

Regular Expressions cheat sheet

Basic matching

Each symbol matches a single character:

. anything 1 \d digit in 0123456789 \D non-digit \w “word” (letters and digits and _) \W non-word ␣ space \t tab \r return \n new line 2 \s whitespace (␣, \t, \r, \n) \S non-whitespace

Character classes

Character classes [...] match any of the charac- ters in the class. Ex: [aeiou] matches vowels. Use ˆ to specify the complement set: [ˆaeiou] matches non-vowels (including non-letters!). Use - to specify a range of letters: [a-e] matches abcde and [0-9a-f] matches ‘0123456789abcdef‘.

Boundaries

Boundary characters are helpful in “anchor- ing” your pattern to some edge, but do not select any characters themselves. \b word boundaries (defined as any edge between a \w and \W) \B non-word-boundaries ˆ the beginning of the line $ the end of the line Ex: \bcat \b finds a match in “the cat in the hat” but not in “locate”.

Disjunction

(X|Y) X or Y Ex: \b(cat|dog)s\b matches cats and dogs.

“Quantifiers”

X* 0 or more repetitions of X X+ 1 or more repetitions of X X? 0 or 1 instances of X X{m} exactly m instances of X X{m,} at least m instances of X X{m,n} between m and n (inclusive) in- stances of X By default, quantifiers just apply to the one character. Use (...) to specify explicit quanti- fier “scope.” Ex: ab+ matches ab,abb,abbb,abbbb... (ab)+ matches ab,abab,ababab... Quantifiers are by default greedy in regex. Good regex engines support adding? to a quantifier to make it lazy. Ex: greedy: ^.b aabaaba lazy: ^.?b aabaaba

Special characters

The characters {}^$.|*+?\ (and - inside [...]) have special meaning in regex, so they must be “escaped” with \ to match them. Ex: . matches the period. and \ matches the backslash .

Backreferences

Count your open parentheses ( from the left, starting with 1. Whatever is matched by paren- thesis number n can be referenced later by \n. Ex: \b(\w+)␣\1\b matches two identical words with a space in between Backreferences are useful for find/replace s: Ex: Finding \b (\w +)er\b and replacing with more \1 will map “the taller man” 7 → “the more tall man” and “I am shorter” 7 → “I am more short”.

Advanced

Read about “non-capturing parentheses” and “look-ahead” and “look-behind” online. Also, visualize your regexes as finite-state machines at http://www.regexper.com/. 1 ...except line breaks, depending on your engine. 2 Depending on where you got your file, line breaks may be \r, \n, or \r\n. Also, in some regex engines (e.g. TextWrangler), \r and \n match the same things.

Hadas Kotek (courtesy of Michael Y. Erlewine)