Table of Contents

YuPcre2: Changes from DIRegEx

YuPcre2 is an up to date regular expression library for Delphi with Perl syntax. Directly supports UnicodeString, AnsiString, or UCS4String, as well as UTF-8, and UTF-16.

This document describes the differences and similarities between the new YuPcre2 and the old DIRegEx to help convert existing projects. If you never used DIRegEx or start a new project with YuPcre2, you might skip this document.

YuPcre2 is a new project, not just a drastic update to DIRegEx. A lot has changed, even though some units, classes, and functions carry familiar names. Unfortunately, it was not possible to keep identical identifiers because Delphi rejects them if both YuPcre2 and DIRegEx are installed into the IDE. Overall, DIRegEx names have changed to DIRegEx2 where possible, which should simplify transition to YuPcre2.

Unit Name Changes

Unit names had to be changed to allow YuPcre2 to be installed into the IDE in parallel with DIRegEx. Unit names start with the YuPcre2 prefix. The native PCRE2 API is in YuPcre2.pas. DIRegEx units with class wrappers and helper routines have been renamed to YuPcre2_RegEx2…:

DIRegEx YuPcre2
DIRegEx_Api.pas YuPcre2.pas
n/a YuPcre2OptInfo.pas
DIRegEx_Reg.pas YuPcre2Reg.pas
DIRegEx.pas YuPcre2_RegEx2.pas
DIRegEx_Consts.pas YuPcre2_RegEx2_Consts.pas
DIRegEx_MaskControls.pas YuPcre2_RegEx2_MaskControls.pas
DIRegEx_SearchStream.pas YuPcre2_RegEx2_SearchStream.pas
DIRegEx_Utils.pas YuPcre2_RegEx2_Utils.pas

Class and Identifier Name Changes

Class names now contain “RegEx2” – the number 2 is appended to “RegEx”. Most members, helper routines and identifier names are unchanged. Deprecated warnings are issued where appropriate.

DIRegExYuPcre2
TDIPerlRegEx16 TDIPerlRegEx16TDIPerlRegEx2_16.png TDIPerlRegEx2_16
TDIDfaRegEx16.gif TDIDfaRegEx16 TDIDfaRegEx2_16.png TDIDfaRegEx2_16
TDIPerlRegEx.gif TDIPerlRegEx TDIPerlRegEx2_8.png TDIPerlRegEx2_8
TDIDfaRegEx.gif TDIDfaRegEx TDIDfaRegEx2_8.png TDIDfaRegEx2_8
TDIRegExMaskEdit.gif TDIRegExMaskEdit TDIRegEx2MaskEdit.png TDIRegEx2MaskEdit
TDIRegExMaskComboBox.gif TDIRegExMaskComboBox TDIRegEx2MaskComboBox.png TDIRegEx2MaskComboBox

TDIRegEx2Base.CompileOptions is empty by default. In DIRegEx, coCaseLess and coDotAll were set by default. YuPcre2 excludes them for compatibility with PCRE2. If matching relies on these options, set them like this:

{ Set YuPcre2 CompileOptions to DIRegEx default: }
RegEx.CompileOptions := [coCaseLess, coDotAll];

TDIRegEx2Base.BSR and TDIRegEx2Base.NewLine options are new properties of their own. In DIRegEx they were be part of the CompileOptions and MachOptions. As a consequence, BSR and NewLine options can no longer be passed to CompileMatchPatternStrOpt but must be set beforehand.

PCRE2 Native API Changes

PCRE2 Funcionality Changes