Skip to main content

Spam Filter

Spam Filter Project Preview – screenshot showing a message correctly identified as spam Spam Filter Project Preview – screenshot showing a message correctly identified as not spam

The Project

Spam filter developed with Regular Expressions (Regex), real-time message validation and advanced pattern matching. An application that identifies spam messages through a deny list of specific regex patterns.

Source Code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Learn Regular Expressions by Building a Spam Filter</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>
<header class="main-text">
<h1 class="title">Is this Spam?</h1>
<p class="description">
Enter a phrase to check if it would be marked as spam or not.
</p>
</header>

<main>
<label class="message-label" for="message-input">Message: </label>
<textarea
placeholder="Enter message here"
value=""
type="text"
name="message"
id="message-input"
rows="10"
cols="40"
></textarea>
<button class="btn" id="check-message-btn" type="button">
Check message
</button>
<p id="result"></p>
</main>
<footer class="footer">&copy; freeCodeCamp</footer>
<script src="./script.js"></script>
</body>
</html>

Two Weeks of Strategic Break

Almost two weeks have passed since the last project because I decided to pause the freeCodeCamp curriculum to complete Course 5 of the Google UX Certificate.
This wasn't just a study break. I used this time to prototype a real-world Maintenance App for the factory where I worked. It turned into a massive lesson on User Research failures and adapting UI to industrial environments (switching from Material to Metro Design).
I have documented this entire detour, including the analysis of my recruiting mistakes, in a dedicated Case Study.

Read the Maintenance Case Study

The Spam Filter Project

That said, this Spam Filter was a short project but to which I devoted more time than I thought for a specific reason: I summarized all the new concepts, I went beyond the cases that freeCodeCamp explained to me and now I have valuable material ready to be integrated into the vademecum.

What I Learned

Regular Expressions (Regex) Fundamentals:

  • Pattern matching with /pattern/flags
  • Flag i for case-insensitive matching
  • Character classes and alternation [e3] for variants
  • Non-capturing groups (?:pattern) for organization
  • Boundary matching (?:^|\s) for word boundaries

Advanced Regex Patterns:

  • Quantifiers +, *, ? for variable occurrences
  • Lookahead and lookbehind assertions
  • Escape sequences for special characters
  • Alternative character matching [o0], [e3], [a@4]

Array Methods with Regex:

  • .test() to verify pattern match
  • .some() to test array of regex
  • Functional programming for validation logic

Spam Detection Patterns:

  • Deny list approach for known patterns
  • Multiple regex combinations
  • Leet speak detection (fr[e3][e3], m[o0]n[e3]y)
  • Context-aware pattern matching

UX Research Methodologies:

  • Blue sky research for design innovation
  • Moderated vs unmoderated usability testing
  • Test script design and task formulation
  • Bias awareness and mitigation

Lessons from Usability Testing:

  • Message format: voice > long text
  • Clear incentives from the start
  • Instruction simplification
  • Task ordering importance
  • "Don't Make Me Think" principle in action

Design System Evolution:

  • From Material Design to Metro Design
  • Platform-specific design choices
  • Comfort zone consideration for users

Professional Growth:

  • Ownership of errors
  • Iterative testing approach
  • User-centered thinking
  • Complete documentation for vademecum

Next Project: Learn Basic Algorithmic Thinking by Building a Number Sorter