Using Regular Expressions

If you’re a servlet programmer with a background in Perl-based CGI scripting and you’re still smitten with Perl’s regular expression capabilities, this section is for you. Here we show how to use Perl 5 regular expressions from within Java. For those of you who are unfamiliar with regular expressions, they are a mechanism for allowing extremely advanced string manipulation with minimal code. Regular expressions are wonderfully explained in all their glory in the book Mastering Regular Expressions by Jeffrey E. F. Friedl (O’Reilly).

With all the classes and capabilities Sun has added in JDK 1.1 and JDK 1.2, one feature still absent is a regular expression engine. Ah, well, not to worry. As with most Java features, if you can’t get it from Sun, a third-party vendor is probably offering what you need at a reasonable price.

Several companies offer full-featured regular expression engines. One of the first was Thought, Inc., which developed VanillaSearch. It’s available for trial download and purchase at http://www.thoughtinc.com . More recently, Original Reusable Objects, Inc. has come out with a product called OROMatcher (along with a utility package built using OROMatcher called PerlTools). These products are available for download at http://www.oroinc.com . A binary license to use OROMatcher and PerlTools is being offered absolutely free. Support, source, and “mere” redistribution (that is, as added value to an IDE) cost extra.

Improving Deblink with ...

Get Java Servlet Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.