In plain words
A regular expression is a short pattern of symbols that describes what text should look like, so code can search, check or clean it.
Where you see it
A dense run of symbols between two forward slashes, like /^[^\s@]+@[^\s@]+$/. Your agent writes one to check emails on a signup form or to pull hashtags out of a Chirp post.
What goes wrong
- An email check that turns away real people
Strict patterns reject valid addresses with a + or an unusual domain, like maya+quill@studio.design. Check for an @, then confirm by sending an email.
- Missing ^ and $
Without them the pattern only has to match somewhere inside the text, so a digits-only check passes "abc123xyz".
/\d+/.test("abc123xyz") // true - Trusting a pattern nobody can read
If no one on the project can explain a regex, no one can tell when it's wrong. Make the agent break it down and show examples that pass and fail.
What to tell your agent
Quick check
Sign in to earn +10 XP for itA phone field uses /\d+/ to allow digits only, yet "call me 0712" passes. What's missing from the pattern?