liveBook · Manning

Regular expression

As explained in Build Financial Software with Generative AI (From Scratch)

A regular expression is a pattern notation for matching and manipulating text according to specified character and repetition rules.

A regular expression describes text patterns for validation or extraction. It can check whether an email has an expected structure or capture a filename from an automated test step. section 1.5.4 section 8.3.4

Use regular expressions carefully in production code:

  • Review generated patterns before adopting them; the maintainer remains responsible when the code fails. section 1.5.4
  • Ask for documentation and standards when a pattern is unfamiliar, such as Perl documentation or RFC 5322 for email syntax. section 1.5.4
  • Prefer simpler parsing when it expresses the requirement clearly; replacing captures with named placeholders can improve maintainability. section 8.3.4

Validating an email with Perl

A generated Perl one-liner matches an email against character, separator, domain, and top-level-domain rules, then prints whether the address is valid. Treat the pattern as code to inspect and test, not as an unquestioned answer. section 1.5.4

perl -e 'my $email = "user@example.com"; if ($email =~ /^[a-zA-Z0-9._%+-
]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) { print "$email is a valid email address.\n"; } else { print "$email is an invalid email address.\n"; }'

Shows the complete Perl email-validation command and its regular expression. section 1.5.4

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Shows generated validation and named captures, but stops short of teaching regex syntax or matching-engine internals.
Examples
Uses a Perl email-validation one-liner and regex-based ACH filename capture in step definitions.
What you can do after
Evaluate generated regex code, validate an email example, and simplify captured-string parsing when direct parsing is clearer.
How it connects
Connects regular expressions with generative AI, Perl, email standards, string parsing, and maintainability.

Also explained in

Compare how 27 books explain regular expression →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.