Every few months I need to answer a question that sounds simple: “is this string valid?” Is it an email address, an IPv6 address, a URI, a CSV file? The usual answer is a regular expression, and the usual regular expressions you find online are wrong in some edge case nobody tested. In my case I wanted to parse email addresses accurately, strictly and according to the agreed rules.
The standards bodies already wrote these rules down, precisely, in a notation designed for exactly this job called Augmented Backus Naur Form (ABNF). So I wrote an engine that reads that notation. It’s an ABNF implementation in Oracle object types and PL/SQL, and the code is in the ABNF repo on my GitHub.
Continue reading