# Outline for December 3, 2020

Due: Homework 4, due December 1, 2020
Project, due December 18, 2020

1. The backslash and patterns
1. How the Python interpreter and Python pattern matcher interact
2. Raw strings

2. Useful functions/methods [recomp.py, renocomp.py, regroup.py]
1. re.compile(str) compiles the pattern into pc (that is, pc = re.compile(str))
2. pc.match(str) returns None if compiled pattern pc does not match beginning of string str
3. pc.search(str) returns None if pattern pc does not match any part of string str
4. pc.findall(str) returns a list of substrings of the stringstr that match the pattern pc
5. pc.group(str) returns the substring of the string str that the pattern pc matches
6. pc.start(str) returns the starting position of the match
7. pc.end(str) returns the ending position of the match
8. pc.span(str) returns tuple (start, end) positions of match
3. Useful abbreviations
1. \d matches any digit; same as [0-9]
2. \s matches any space character; same as [ \t\n\r\f\v]
3. \w matches any alphanumeric character and underscore; same as [a-zA-Z0-9_]
4. \D matches any character except a digit; inverse of \d
5. \S matches any character except a space character; inverse of \s
6. \W matches any character except an alphanumeric character or underscore; inverse of \w
7. \b matches a word boundary — a word is a sequence of alphanumeric characters

4. Thinking recursively [recfun.py]
1. First: think of the recursive case (write the problem in terms of something involving a smaller instance of the problem)
2. Next: think of base case (when to stop)
3. Example: Does the string only have alphabetic characters in it?

5. Recursion
1. n factorial [nfact.py]

 Matt Bishop Office: 2209 Watershed Sciences Phone: +1 (530) 752-8060 Email: mabishop@ucdavis.edu
MHI 289I, Programming for Health Informatics
Version of December 2, 2020 at 11:20PM