XML technologies / Regular expressions / How regex engines work / Start the engine!

(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)

Let us see how far we can take the engine analogy. An engine supplies the power that moves a car from point A to point B. It does the work while you relax in your leather seat and enjoy the stereo. Its job is to turn the wheels; how it does so is unimportant. Or is it?

Two kinds of engines

Why not an electric car? They have existed for a long time, but technical difficulties allowed gasoline and diesel cars to prevail. With an electric car, you would hardly fill the “tank” with gasoline. Conversely, gasoline requires care around sparks. An electric motor simply runs, whereas a combustion engine occasionally needs adjustment. Details such as spark-plug gaps, air filters, or even fuel brands affect performance. Neglect maintenance and performance declines, or worse, the engine stops.

Whatever principle the engine uses, what matters is that it moves the car. You still have to accelerate, brake, and steer, of course, but that is another matter.

California emissions standards

Add a new variable: California emissions standards. (Note: California has very strict standards, so many American car models come in California and non-California versions.) Some engines meet them, others do not. These are usually variants of familiar types, rather than fundamentally different engines. The standard specifies only what may come out, without saying how to meet the limits. We now have four types: compliant and noncompliant electric motors, and compliant and noncompliant combustion engines.

On closer inspection, an electric motor meets the rules easily: the standard more or less approves the existing situation. A combustion engine, however, needs substantial adjustments, perhaps redesigned parts, before meeting the standard. Owners of such cars must be very careful about what goes into the tank: the wrong fuel quickly causes all sorts of problems.

Effects of standards

Better emissions standards are certainly beneficial, but require drivers to follow some rules, at least when refueling. They do not affect most Americans, however, because the other states do not follow California standards.

Thus the four engine types can be grouped into three classes: two combustion and one electric. You know their differences and that they all ultimately propel the car. What you do not know is what any of this has to do with regular expressions.

  

  

 

 

 

German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.

O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln

back to top