Sign in Join

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

Mailing lists / fpc-pascal / 2010-06

regex vs synregexpr unit

11 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Bihar Anwar

I've search fpc mailing list about this matter, I found they were discussed a long time ago (2006), and I still didn't have a conclusion about which one should be used. I need an advice about which unit should be used in terms of features, speed, etc.

Also, if someone here know a better approach to implement full-featured regular expression in our FPC programs, please let me know it.

Thanks in advance.

spir
to Bihar Anwar
I've search fpc mailing list about this matter, I found they were discussed a long time ago (2006), and I still didn't have a conclusion about which one should be used. I need an advice about which unit should be used in terms of features, speed, etc. Also, if someone here know a better approach to implement full-featured regular expression in our FPC programs, please let me know it.

Interested, too. And with a PEG library, if any (have searched, already); If there is none, I'll have to build one in a few weeks.

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com

Bihar Anwar

Schindler Karl-Michael wrote on June 6, 2010 1:09:02 AM:

The pcre library (written in C) has a good reputation. You can get

pascal headers from the Project JEDI Code Library (JCL).

Wow, that seems a more promising approach in the current time, I'll look on it. Thanks so much.

BTW, which approach should be used to call C functions from FPC: call them through DLL, or compile the C source into an .o file then link it with FPC code?

Graeme Geldenhuys
to Bihar Anwar: I've search fpc mailing list about this matter, I found they were discussed a long time…
Bihar Anwar wrote
I've search fpc mailing list about this matter, I found they were discussed a long time ago (2006), and I still didn't have a conclusion about which one

I have looked into this as well, about 2 months ago. From my initial research it seems the regex unit included with FCL is not as feature-complete as the one in SynEdit.

I found another Object Pascal implementation of regular expressions. It is somewhere in my hard drive (can't remember the download link), but I think it was similar in feature supported as the one in SynEdit.

I haven't done any speed comparisons to date. I also know about the CPRE library, but I want something implemented in Object Pascal to compile into my applications.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/
Juha Manninen
to Bihar Anwar: I've search fpc mailing list about this matter, I found they were discussed a long time…

I also chose SynEdit for Lazarus Delphi converter for some reason. (I think it was the first hit when searching "regexp" from Lazarus code base). It works well.
I would guess the other choices work well, too.

About the speed difference: I don't believe there is any huge difference. Please remember that if speed is really an issue for your application then you must forget regexp and make your own pascal code to parse the string.

Juha

Bihar Anwar
to Juha Manninen
Graeme Geldenhuys wrote
I have looked into this as well, about 2 months ago. From my initial research it seems the regex unit included with FCL is not as feature-complete as the one in SynEdit.
Juha Manninen wrote
I also chose SynEdit for Lazarus Delphi converter for some reason. I think it was the first hit when searching "regexp" from Lazarus code base. It works well. I would guess the others work well too.

Thanks Graeme and Juha for the information.

Juha Manninen wrote
Please remember that if speed is really an issue for your application then you must forget regexp and make your own pascal code to parse the string.

Speed is important to me, but reg-expr features is important as well. Actually, I want to include reg-expr as an alternative search mode in my general-purpose file search unit.

Juha Manninen
to Bihar Anwar

Hi

Speed is important to me, but reg-expr features is important as well. Actually, I want to include reg-expr as an alternative search mode in my general-purpose file search unit.

Then the SynEdit's version of regexp should be fast enough. SynEdit editor in Lazarus for example uses it and it's quite fast. File I/O is the slowest part when searching from files.

Juha

Flávio Etrusco
to Juha Manninen

http://delphi.about.com/od/toppicks/tp/delphi-regular-expressions.htm

The regex unit in SynEdit is an old version of the code from regexpstudio.com (which seems to be offline) is said to be very slow for processing large sets of data, like a whole file. In SynEdit it`s used to process single lines, and in this situations it seems pretty good.

Best regards,
Flavio

Juha Manninen wrote 15 lines
Hi > Speed is important to me, but reg-expr features is important as well. > Actually, I want to include reg-expr as an alternative search mode in > my general-purpose file search unit. Then the SynEdit's version of regexp should be fast enough. SynEdit editor in Lazarus for example uses it and it's quite fast. File I/O is the slowest part when searching from files. Juha _______________________________________________ fpc-pascal maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Bihar Anwar
to Flávio Etrusco

OK guys, after contemplating all your suggestions, I decide to follow the SynEdit way, that is, synregexpr unit. I suppose this unit tends to get more maintenance in the future.

Concerning the C++ PCRE library, it is the most full-featured reg-expr implementation, but calling C++ functions from FPC code in a cross-platform way is complex enough and causes of possible crash will be hard to investigate.

Cheers.

Joost van der Sluis
to Graeme Geldenhuys: I have looked into this as well, about 2 months ago. From my initial research it seems…
Graeme Geldenhuys wrote 7 lines
On 05/06/2010, Bihar Anwar wrote: > I've search fpc mailing list about this matter, I found they were discussed > a long time ago (2006), and I still didn't have a conclusion about which one I have looked into this as well, about 2 months ago. From my initial research it seems the regex unit included with FCL is not as feature-complete as the one in SynEdit.

Bug-report numbers? ;)

As far as I know, the fcl-version follows the regex standard exactly and completely. But the synedit version doesn't. You could try to run the regexpr-tests from the fcl with the synedit version, see how it works.

But there are a lot of additions and regexp-dialect out there.

I thought that the main difference between the synedit regex and the fcl-regex, is that the synedit version also supports the 'usual' search patterns like '*'.

Joost.