Easily Use Regular Expressions in Your Delphi Source Code

RegularExpressions unit in Delphi XE and Later

Delphi XE was the first release of Delphi to include support for regular expressions in the RTL. The RegularExpressionsCore unit contains the TPerlRegEx class, which is a wrapper around the PCRE library along with search-and-replace and split support. The RegularExpressions unit contains a set of records such as TRegex and TMatch that mimic the .NET classes such as Regex and Match.

      
Only US$ 39.95
Windows XP, Vista, 7, 8, 8.1, 10, and 11
100% satisfied or money back

Delphi for Win32 TPerlRegEx VCL Component

If you are using Delphi 2010 or earlier to create Win32 applications, you will need to use a third party VCL component. RegexBuddy’s Win32 Delphi source code snippets are based on the TPerlRegEx VCL component. This component is a wrapper around PCRE, with additional support for replace and split actions. The RegularExpressionsCore unit in Delphi XE is actually a slightly modified version of this component. You can download TPerlRegEx for free. TPerlRegEx Delphi source, PCRE C sources, PCRE OBJ files and DLL are included. You can choose to link the OBJ files directly into your application, or to use the DLL.

//tp.embarcadero.com/ctprefer?partner_id=460&product_id=0">Just Great Software is proud to be an Embarcadero Technology Partner

Delphi Prism and Delphi for .NET Using the CLR Regex Classes

Delphi Prism was Embarcadero’s variant of the Delphi language specifically developed to target the .NET framework. Delphi Prism lived inside the Visual Studio IDE. It was based entirely on the .NET framework.

Delphi 8, 2005, 2006, and 2007 included a Delphi for .NET compiler for developing WinForms and VCL.NET applications. Though Delphi for .NET only supported .NET 1.1 or 2.0, depending on your Delphi version, you could still use .NET’s full regular expression support.

Though both Delphi Prism and Delphi for .NET have long been discontinued, RegexBuddy still supports them. If your old code needs a new regex, you can easily create and test that with RegexBuddy. If you want to migrate your Delphi code that was targeting .NET to the VCL or to FireMonkey, you can use RegexBuddy to convert your regexes from the .NET flavor to the PCRE flavor.

See How Easy Coding with Regexes Can Be

First, use RegexBuddy to define a regex or retrieve a regexp saved in a RegexBuddy library. Rely on RegexBuddy’s clear regex analysis, which is constantly updated as you build the pattern, rather than dealing with the cryptic regex syntax on your own. Detailed help on that syntax is always only a click away.

If you copied a regex written for another programming language, simply paste it into RegexBuddy, select the original language, and then convert the regex to the specific version of Delphi you’re working with. If you’re developing a component that needs to work with multiple versions of Delphi, compare your regex between those Delphi versions to make sure it will work exactly the same with all of them. RegexBuddy supports all Delphi versions, including the latest 11 Alexandria.

If you created a new regular expression, test and debug it in RegexBuddy before using it in your Delphi source code. Test each regex in RegexBuddy’s safe sandbox without risking precious data. Quickly apply the regex to a wide variety of input and sample data, without having to produce that input through your application.

Finally, let RegexBuddy generate a source code snippet that you can copy and paste directly into the RAD Studio IDE, or whichever Delphi code editor you use. Choose what you want to use the regex for and a fully functional code snippet is ready. You can change the names of variables and parameters to suit your naming style or the current situation, which RegexBuddy automatically remembers. You can generate code snippets that use the RegularExpressions unit or the RegularExprssionsCore unit in Delphi XE and later. You can also generate snippets using the classic TPerlRegEx component for earlier Delphi versions. You can even generate code snippets for Delphi Prism (Oxygene) or the discontinued Delphi for .NET compiler using the .NET regex classes.

While TRegEx, TPerlRegEx, and the .NET Regex classes are all quite different, you don’t have to remember the details of how to use either of them. Just tell RegexBuddy what you want to do, and you will get the proper the proper code for your Delphi version and variant straight away. Anything can be done: testing a string for a match, extracting search matches, validating input, search-and-replace, splitting a string, etc.




Let RegexBuddy Make Regex Easy for You