Here’s a quirky little example of an AI (GPT-3) based project, to help you with creating RegEx, check it out:

In this video, Erik explores a fascinating AI-powered tool that attempts to convert plain English descriptions into regular expressions using OpenAI’s GPT-3 language model. He demonstrates the tool’s capabilities and limitations, and connects it back to his RegEx Workbench for Business Central that was featured in a previous video.
The Promise: English to RegEx with GPT-3
The concept is deceptively simple — someone took GPT-3, OpenAI’s language prediction model trained on approximately 175 billion parameters, and used it to generate regular expressions from plain English descriptions. The tool, hosted at autoregex.xyz, lets you type in what you want to match and it attempts to produce a working regex pattern.
GPT-3 is remarkable in its ability to produce text and carry on near-conversational interactions. Applying it to the notoriously difficult domain of regular expressions is a creative use case that could save developers significant time and frustration.
Live Demonstration
Erik tests the tool with several prompts to see how well it performs:
- “At least eight characters and numbers” — The tool returns a regex pattern for this common password-style requirement.
- “US zip code” — A straightforward test that produces a pattern, including the optional four-digit extension (ZIP+4 format).
- “Minimum eight characters, at least one letter and one number” — A classic password validation regex that the tool handles well.
- “US phone number” — The tool generates a pattern, though testing it in the RegEx Workbench reveals some quirks with the surrounding anchors and formatting expectations.
- “Canadian zip code” — This produces a pattern that Erik tests against a real Canadian postal code.
- “Secure password” — The model responds with a pattern and even includes the English note that it “should be at least 8 characters long,” showing how the AI sometimes blurs the line between generating regex and generating natural language responses.
- “An amount” — This one stalls out and produces something unhelpful, highlighting the tool’s limitations.
The results are mixed — sometimes impressively accurate, other times producing patterns that don’t quite work or returning English text alongside the regex. The model’s confidence varies, and you can get different results by hitting the generate button multiple times for the same prompt.
The RegEx Workbench in Business Central
To test the generated patterns, Erik uses his custom RegEx Workbench built for Business Central. This is the same tool from his earlier video on regex. It provides a card page where you can enter input data, specify a pattern, and see the matches rendered in a list.
The Workbench Page
The main page ties everything together — an input field, a pattern field with an assist edit for looking up common patterns, and a results part that displays matches:
page 51100 "RegEx Workbench"
{
PageType = Card;
Caption = 'RegEx Workbench';
UsageCategory = Administration;
ApplicationArea = all;
layout
{
area(Content)
{
field(InputData; InputData)
{
Caption = 'Input';
ApplicationArea = all;
MultiLine = true;
}
field(Pattern; Pattern)
{
Caption = 'Pattern';
ApplicationArea = All;
trigger OnAssistEdit()
var
PatRec: REcord "RegEx Pattern";
begin
if page.RunModal(Page::Patterns, PatRec) = action::LookupOK then
Pattern := PatRec.RegEx;
end;
}
part(Matchpart; "RegEx Matches")
{
ApplicationArea = all;
}
}
}
actions
{
area(Processing)
{
action(MatchAction)
{
caption = 'Match';
ApplicationArea = All;
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
PromotedOnly = true;
trigger OnAction()
var
RegEx: Codeunit Regex;
begin
RegEx.Match(InputData, Pattern, Matches);
CurrPage.Matchpart.Page.Fill(InputData, Matches);
end;
}
}
}
var
Matches: Record Matches;
InputData: Text;
Pattern: Text;
}
The workbench uses the built-in Regex codeunit from the System Application to perform the actual matching. When you click the Match action, it runs the regex against your input and populates the temporary matches table.
Displaying Matches
The matches are displayed in a list part that uses a temporary table. A key detail is how the matched text is extracted — since the Matches record stores an index and length, the actual matched substring is pulled from the original input data:
page 51101 "RegEx Matches"
{
PageType = ListPart;
SourceTable = Matches;
SourceTableTemporary = true;
Editable = false;
layout
{
area(Content)
{
repeater(rep)
{
field(Index; Rec.Index)
{
ApplicationArea = All;
}
field(MatchIndex; Rec.MatchIndex)
{
ApplicationArea = All;
}
field(Success; Rec.Success)
{
ApplicationArea = All;
}
field(Length; Rec.Length)
{
ApplicationArea = All;
}
field(Data; GetData(Rec))
{
ApplicationArea = all;
Caption = 'Match';
}
}
}
}
procedure GetData(m: Record Matches): Text
begin
exit(copystr(InputData, m.Index + 1, m.Length));
end;
procedure Fill(_InputData: Text; var m2: Record Matches)
begin
InputData := _InputData;
rec.deleteall();
if m2.findset() then
repeat
rec.copy(m2);
rec.insert();
until m2.next() = 0;
end;
var
InputData: Text;
}
Note the m.Index + 1 in the GetData function — this accounts for the fact that regex uses zero-based indexing while AL’s CopyStr function uses one-based indexing.
A Built-in Pattern Reference
The workbench also includes a comprehensive pattern reference table that serves as a regex cheat sheet right inside Business Central. It covers everything from basic character classes to lookaheads and includes practical examples like email validation, date matching, and decimal numbers:
table 51100 "RegEx Pattern"
{
fields
{
field(1; RegEx; Text[250])
{
Caption = 'RegEx';
}
field(2; Description; Text[1000])
{
Caption = 'Description';
}
}
keys
{
key(PK; RegEx) { }
}
procedure create()
begin
InsertRec('\', 'Marks the next character as either a special character or escapes a literal...');
InsertRec('\d', 'Matches a digit character. Equivalent to [0-9].');
InsertRec('\w', 'Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]".');
InsertRec('([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})',
'Matches a valid email address');
InsertRec('(\+|-)?[0-9]+(\.[0-9]*)?', 'Matches a decimal number');
// ... and many more patterns
end;
}
This pattern table is accessible via the assist edit button on the Pattern field, giving you a quick lookup for common regex patterns without needing to leave Business Central.
The Reality Check
While the concept of AI-generated regex is exciting, Erik’s live testing reveals that the technology is not quite there yet. Some key observations:
- Results are non-deterministic — running the same prompt multiple times can produce different patterns.
- The model sometimes responds in English instead of (or in addition to) regex, blurring the line between explanation and output.
- Some generated patterns work well for simple cases but struggle with more complex or ambiguous requests.
- Running queries against GPT-3 costs money, so free tools like this may not stay available indefinitely.
Conclusion
The idea of using AI to translate plain English into regular expressions is genuinely compelling — regex is one of those areas where even experienced developers often struggle. While the GPT-3 powered tool at autoregex.xyz shows real promise, it’s not yet reliable enough to blindly trust its output. The smart approach is to use it as a starting point, then validate the generated patterns using a tool like the RegEx Workbench in Business Central. As AI models continue to improve, this kind of natural-language-to-code translation will only get better — and the combination of AI-assisted pattern generation with a proper testing workbench could become a powerful workflow for Business Central developers.