Fall 2026
  • Discord
  • Gradescope
  • Syllabus

On this page

  • Start
  • Inspect and redact
  • Check and submit

Lab: Redacted

Due: Wednesday, November 18 at 11:59pm (one week after it is assigned) · Worth: 4 points

Regular expressions can help us find contact information in text and hide sensitive numbers before sharing a report. You’ll work with fictional campus-visit tickets that use public admissions contacts from the seven Claremont Colleges. The Social Security and card numbers are made up.

Start

Download and extract the starter ZIP. Open the inner lab-regex folder in VS Code, then initialize and publish your repository as lab-regex. Open lab_regex.py and support_tickets.json. The input separates message, contact, and card fields.

Inspect and redact

Complete the twelve helpers using their docstrings and doctests. Use the regex reading and its reference table for pattern syntax and the re functions. Write patterns as raw strings.

Start with the helpers that find digits and contact details. Then write the ones that validate email addresses and redact sensitive fields. The starter specifies which formats each pattern should recognize.

  • Implement has_digit, find_numbers, and mask_digits: check for any digit, extract consecutive digit runs as strings, and replace each digit with X.

  • Implement find_phone_numbers and area_code using the formats in their doctests. Implement is_valid_email to check the whole string, rejecting extra text and a trailing newline. Preserve the order of phone-number matches and keep duplicates.

  • Implement find_urls, find_hashtags, and find_mentions using the formats in their doctests. Preserve match order and duplicates.

  • Implement redact_emails, redact_ssns, and mask_last_four. Replace emails with [REDACTED], SSNs with XXX-XX-XXXX, and all but the last four digits of a sixteen-digit card with stars.

Check and submit

Run:

python -m doctest lab_regex.py
python review_packet.py

You can run individual report stages with python review_packet.py --stage inspect, index, validate, or redact. In the complete report, the first contact is valid and the second is invalid. The first card becomes ************5678. Check that redaction leaves ordinary message text unchanged.

Commit and sync lab_regex.py. On Gradescope, choose GitHub and submit lab-regex and the branch containing your work. The submission guide explains resubmission.