Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-05

Re: Mattias Gaertner: regexpr

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

L505

Knock knock, is anyone home on Sunday in Netherlands and elsewhere? The list is quiet... ;-)

Well, I looked through the Lazarus sources and Synedit sources, because I remember the fact that synedit had it's own semi modified version of Regexpr Studio's Tregexpr. And hey, if Lazarus runs on GnuLinux, and it uses Synedit, how is it using regular expressions?? It must be using them.. sooooo.....Of course, I went in and found that synregexpr unit. Then I just commented out some of the IfDef's for syn_Lazarus and renamed the unit to "Regexpr2.pas".

Compiler eats up the Regexpr2 I made with no troubles. So now I can use regular expressions in freepascal without problems, for generic uses (not just for synedit!).

I think we should put this unit up in the contributed units section on the FreePascal.org website. I'll put it on my FTP too, because I'm sure others are looking for a working regular expression unit with back references. Hopefully I can also notify the owner of RegexprStudio website to put the Regexpr2.pas unit I made, because his website only offers a freepascal regexpr unit that works on Win32 right now.

Of course we always have the other regexpr unit by Florian to work on also.. since it's not completed yet.

Example simple regular expression program working in Linux

Program ExampleRegexpr;
Uses
 Regexpr2;

{
Program to demonstrate the secondary Regular expression unit Note: not the one by Florian, but the RegexprStudio. }

const
 InputStr : PChar = 'This is a simple string.';
var
      TestRgx:tregexpr;
begin
   testrgx:=tregexpr.create;
   testrgx.expression:='i(.*)P';
   testrgx.exec(InputStr);
   writeln('The main match: ' + testrgx.Match[0]);
   writeln('The first back reference match: ' + testrgx.Match[1]);
   If testrgx  nil then
   begin
    testrgx.free; //should have used FreeAndNil!
    testrgx.nil;
   end;
   readln;
end.

Lars
Canada

Earlier message 15 lines
----- Original Message ----- | | Attn: Mattias..(or anyone else who knows about regexpr units) | | Do you know which unit this is that you talked about of above? I'm looking for regexpr units and I wondered | if this unit worked for you with those minor changes you made. The URL does not work and I wondered which unit | that was. If it was the Regexpr Studio, one then I have it. It seems to be geared toward Win32. I will modify | it for linux maybe if this is possible, but I thought maybe you had already found something yourself, or | mucked around and got something working. | I'm looking for a Linux capable regexpr unit with back referencing available. | | Lars |

Reply by email

L505

Oops, error in my last program I sent to the list, I meant this:

Program ExampleRegexpr;
Uses
 Regexpr2;

{
Program to demonstrate the secondary Regular expression unit Note: not the one by Florian, but the RegexprStudio. }

const
 InputStr : PChar = 'This is a simple string.';
var
      TestRgx:tregexpr;
begin
   testrgx:=tregexpr.create;
   testrgx.expression:='i(.*)s';
   testrgx.exec(InputStr);
   writeln('The main match: ',  testrgx.Match[0]);
   writeln('The first back reference match: ',  testrgx.Match[1]);
   If testrgx  nil then
   begin
    testrgx.free; //should have used FreeAndNil!
    testrgx:=nil;
   end;
   readln;
end.
Earlier message 9 lines
----Original Message---- | Program ExampleRegexpr; | Uses | Regexpr2; | { | Program to demonstrate the secondary Regular expression unit | Note: not the one by Florian, but the RegexprStudio. | }

Reply by email