4

Is anyone using Boost for regular expressions in BCB6, or can recommend anything else? I've downloaded the latest boost ZIP file a few times, but I can't get it to unzip yet (my PC is probably not in the best state right now). It is a pretty huge library, so if there is anything else smaller that is just regular expressions, that works well with BCB6, I'd like to try that first. I tried http://www.regular-expressions.info/delphi.html also, but it doesn't have any info about BCB support (just Delphi) and it looks like some of the supplied OBJ files have issues with BCB (and no source code to rebuild those).

Edit: After searching the source code and include folders under CBuilder6\ I found out Builder does have built-in support for regex. So another question is, do they work well, and which set of functions/objects should I use for a VCL-based app? I found TRegexp (but no docs for it) and also some PCRE functions under the CRTL help file (but I'd rather use higher level or C++ if all about the same).

eselk
  • 6,764
  • 7
  • 60
  • 93

1 Answers1

4

The TPerlRegex classes (available at the link you posted above) work fine in C++ Builder. See the section about halfway down the page that refers to older Delphi versions. Best of all, they're free with full Delphi source that will compile in Builder as well.

The components/classes are based on PCRE, and in fact include C source for the .obj files that are used when you compile not to need the DLL, but you can also use it without the .obj files by compiling to require the DLL and distributing the DLL with your app.

The related application to that site, RegexBuddy, can generate strict C-based code for the regexes, or can generate Delphi code (or C++ Builder XE, which can pretty easily be made to work with Builder 6 if you remember that Builder XE is Unicode-based and Builder 6 isn't). (I'm not affiliated with RegexBuddy; I've just been a user since version 1 was released.)

Here's a sample of RegexBuddy 3's C (PCRE) support:

RegexBuddy 3 screen cap

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Which version of RegexBuddy are you using? Mine doesn't offer an option for C at all, only C# or Delphi. – 0xC0000022L Mar 29 '12 at 00:04
  • @STATUS_ACCESS_DENIED: RegexBuddy3; if you use the `Use` tab in the bottom half, you can choose `C` as one of the options. I'll edit my question to include a quick screen cap. – Ken White Mar 29 '12 at 00:12
  • nice, I can also see it there now :) ... thanks for the hint. – 0xC0000022L Mar 29 '12 at 00:14
  • There are about two dozen choices for language now; I just showed C. C#, VB.Net, Java, JavaScript, Perl, PHP, Oracle, and PowerShell are among the others. :) It's a pretty nice enhancement. – Ken White Mar 29 '12 at 00:26
  • I downloaded TPerlRegEx.zip and the readme file says it includes pcrelib.dll, but mine didn't. I tried added PCRE_LINKDLL to my defines and building including the pas files in my project, but still getting a lot of compile errors. I'll try to work my way through them and report back... – eselk Mar 29 '12 at 15:30
  • I got rid of the compiler errors by modifying the top of pcre.pas to define PCRE_LINKDLL instead of including in my global defines, so now I just need to find this pcrelib.dll that is compatible with this library (7.9 unicode C calling conv). – eselk Mar 29 '12 at 15:41
  • The DLL is there (`PCRELIB.DLL`), in the `TPerlRegex\PCRE` folder. See the comments in `PerlRegex.pas` at around line 322: "Functions we import from the PCRE Library DLL", with a list of function prototypes, calling convention `cdecl`, externally statically linked to `pcrelib.dll` following. (There's even a comment related to Builder 6.) – Ken White Mar 29 '12 at 16:20
  • Found the DLL, it is in http://www.regular-expressions.info/download/TPerlRegEx2009.zip, but not in http://www.regular-expressions.info/download/TPerlRegEx.zip. – eselk Mar 29 '12 at 16:37
  • Once I found the DLL, it was easy after that. I left him a comment on his blog incase he didn't know that file was missing from the newer version. Once I got it from the older version download, and used it with the newer version, working great now! Thanks! – eselk Mar 29 '12 at 16:54