Recent versions of TPerlRegEx were missing these two lines in the CleanUp() method after the call to pcre_dispose():
pattern := nil;
hints := nil;
Failing to set the pointers to nil caused TPerlRegEx to attempt to free them multiple times when reusing a TPerlRegEx instance with another regular expression. The latest version fixes this.
Download TPerlRegEx. Source is included under the MPL 1.1 license.
Ever since I updated TPerlRegEx to support Unicode on Delphi 2009, it’s been plagued by a bug in Delphi that triggers an internal error when linking the PCRE OBJ files into your application, if you had TPerlRegEx installed into a design time package. So I changed TPerlRegEx to link in the PCRE code from a DLL instead of the OBJ codes, at least by default.
This bug has been fixed in Delphi 2010. I have updated TPerlRegEx to use the OBJ files by default for Delphi 2010, and the DLL for earlier versions of Delphi. This is the only change. The DLL and OBJ files themselves haven’t changed since August’s release. You can still make Delphi 2010 use the DLL or make older versions use the OBJ files (as long as you don’t use design time packages) by editing the compiler directives at the top of pcre.pas.
Download TPerlRegEx. Source is included under the MPL 1.1 license.
If you have a Safari Books Online subscription, you can start reading Regular Expressions Cookbook on Safari Books Online right now. If you don’t, you can still click that link and then click the red free trial button in the upper right corner of the web page.
When Regular Expressions Cookbook was published as a printed book in June, it was immediately available on Safari in “print fidelity view”. This view loads one page from the printed book at a time as an image. I don’t find that view very useful for technical books. It requires too many clicks and downloads too slow to read comfortably. That’s why I didn’t blog about the Safari edition before.
Safari Books Online now shows Regular Expression Cookbook in HTML format. HTML format loads much faster even while displaying one complete recipe per web page, even if it spans a dozen pages in the printed book.
When Regular Expressions Cookbook was published, I was told by O’Reilly that a Kindle edition would be unlikely, due to the special formatting we use in the book for regular expressions. It seems that those technical difficulties have been overcome, as Amazon now offers a Kindle edition of Regular Expressions Cookbook. I presume the formatting of the Kindle edition won’t be identical to the printed book. I don’t have a Kindle, iPod, or iPhone, so I can’t check.
When I write this, Amazon lists the Kindle edition for $17.59. That’s the lowest price for the book I’ve seen to date. You need a Kindle, iPhone, or iPod Touch to be able to read the Kindle edition. Amazon sells the printed book for $29.70, while O’Reilly sells a DRM-free PDF for $31.99 and the printed book for $44.99.