<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 metachars
. any char
\w any alphanumeric (a-z, A-Z, 0-9, _)
\s any whitespace char (" _, \t, \n)
\S any nonwhitespace
\d any digit (0-9)
. searches for an actual period
Step1:  define your own character classes
inside your regular expression, write [aeiou]
Step2:  metacharacters
^ beginning of string
$ end of string
\b word boundary
Step3:  aside
Step4:  metacharacters 3
Step5:  more metacharacters
<ASSISTANT_TASK:>
Python Code:
#subject lines that have dates, e.g. 12/01/99
[line for line in subjects if re.search("\d\d/\d\d/\d\d", line)]
Explanation: metachars
. any char
\w any alphanumeric (a-z, A-Z, 0-9, _)
\s any whitespace char (" _, \t, \n)
\S any nonwhitespace
\d any digit (0-9)
. searches for an actual period
End of explanation
[line for line in subjects if re.search("[aeiou][aeiou][aeiou][aeiou]", line)]
[line for line in subjects if re.search("F[wW]:", line)]
Explanation: define your own character classes
inside your regular expression, write [aeiou]
End of explanation
[line for line in subjects if res.search("^[Nn]ew [Yy]ork", line)]
[line for line in subjects if re.search(r"\boil\b", line)]
Explanation: metacharacters
^ beginning of string
$ end of string
\b word boundary
End of explanation
x = "this is \na test"
print(x)
x = "this is\t\t\tanother test"
print(x)
normal = "hello\nthere"
raw = r"hello\nthere"
print("normal:", normal)
print("raw:", raw)
Explanation: aside: metacharacters and escape characters
\n new line
\t tab
\ single backslash
(python interprets these)
End of explanation
[line for line in subjects if re.search(r"\b(?:[Cc]at|[kK]itty|[kK]itten)\b", line)]
Explanation: metacharacters 3: quantifiers
        * match zero or more times
        {n} matches exactly n times
        {n,m} matches at least n times, but no more than m times
        {n,} matches at least n times, but maybe infinite times
        + match at least once ({1,})
        ? match one time or zero times
[line for line in subjects if re.search(r"^R
 string matches regular expression if at the first line, you encounter .......
End of explanation
all_subjects = open("enronsubjects.txt").read()
all_subjects[:1000]
#looking for domain names
[line for line in subjectts if re.search](r"\b\w+\.(?:com|net|org)\b", line)
#re.findall(r"\b\w+\.(?:com|net|org)\b", all_subjects)
#"will you pass teh pepper?" re.search "yes"
#"will you pass the pepper?" re.findall "yes, here it is" *passes pepper*
Explanation: more metacharacters: alternation
.......
capturing
read teh whole corpus in as one big string
End of explanation
<END_TASK>