How to expose Regular Expressions to Pascal Script

I have been trying to expose System.RegularExpressions to Pascal Script, but seem to be having problems.

Since it is written as a record, I can’t import it as a class. What is the best way to do it?

Thanks
KenrDavis

I think it would be best to write a simple class wrapper (matching in signatures) around the regex struct and use that from script.

Your the Man! I looked for your email so I could ask you this question, but gave up and posted it here.
Was sure glad that you were the one to reply.

Would it be best to use the TPerlRegEx class, or would that be too much?

Thanks again,
Ken Davis

Looking at http://docwiki.embarcadero.com/Libraries/XE7/en/System.RegularExpressionsCore.TPerlRegEx

that seems like a good candidate.

Well, I seem to be having some problems. I imported PerlRegex.pas and did the necessary things to expose it to the script, and everything compiled ok. But, I am getting the following 2 errors, when I try to compile a bare bones script: monitor.pas
[Error] monitor(1:1) identifier expected
[Error] monitor(1:1) Unable to register type TPerlRegExOptions

which is defined in PerlRegEx.pas as
type
TPerlRegExOptions = set of (

Is what I am doing incorrect ? If so, what should I do ?

Thanks,
Ken

How does the registration script look now?

The bare bones script that I am trying to compile/run is as follows:
program monitor;
var a : integer;
begin
a := a + 1;
end. //very simple.

I am using XE5. To begin, I downloaded a class version of PerlRegEx.pas from Delphi Regular Expressions Classes
I loaded it into the PS Unit Importer, and had 2 errors, importing.

  1.    Offsets: array[0..(MAX_SUBEXPRESSIONS+1)*3] of Integer;
    

I modified it to :
Offsets: array[0…(100*3)] of Integer; // MAX_SUBEXPRESSIONS = 99
2. renamed overloaded function
procedure SplitCapture(Strings: TStrings; Limit: Integer; Offset: Integer); overload;
to
procedure SplitCapturewo(Strings: TStrings; Limit: Integer; Offset: Integer);

I then added it to my program as I do other classes that I have written.
REPlugin := TPSImport_perlregex.create(nil);
TPSPluginItem(TC.Ps.Plugins.Add).Plugin := REPlugin;
It compiles fine, but when I run the program, I get the errors I mentioned.
It doesn’t matter which script I try to run, I get the same errors.
HELP!!
Thanks much,
Ken Davis

Ah hrmm. Set a breakpoint in CMD_Err3, when it hits use the callstack window to find out which registration call it fails on. Odds are it’s something there it doesn’t support.