Regular expressions are a way of describing a pattern match that can be used to select a group of characters from an input string. This usually then leads on to replacing them with some other set of characters. It is analogous to the find and replace capability in a word processor.
JavaScript version 1.2 introduced regular expression support by way of a specialized object, a utility that UNIX developers have long known about and used. It has migrated into many desktop applications now and has become a somewhat portable way of matching text strings with one another and performing edits on them. The regular expression syntax adopted by JavaScript version 1.2 emulates that which is commonly used in Perl interpreters, specifically the syntax that is supported is generally called Perl version 4. In JavaScript version 1.3, the regular expression syntax was expanded to support Perl version 5 syntax.
Regular expressions are managed by creating a RegExp object with the RegExp() constructor. RegExp objects support a literal syntax and can be created on the fly without needing a constructor call which makes them extremely convenient to deploy.
The ECMAScript standard ratifies regular expressions in the third edition. They were not present in the second edition.
Regular expressions are still an area of concern when developing portable content. For example, they are completely unsupported on the WebTV platform as of the Summer 2000 release of the JellyScript interpreter.
Prev | Home | Next |
RegExp pattern - sub-patterns | Up | Relational expression |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |