Until the release of JavaScript 1.2 in Netscape Communicator, developers writing client-side form validation in JavaScript had to write functions which iterated down the characters of a string, checking each character one at a time. Such code is simpler to write than the equivalent CGI scripts and has the advantage of running on any browser which supports JavaScript 1.0 or later. Developers who need to write JavaScript form validation code for use on any JavaScript-capable browser should see Netscape's sample code for form validation using JavaScript 1.0 or later . To make it easier for developers to write scripts which sort, compare, split, or check strings, JavaScript 1.2 has added support for regular expressions. Developers who are writing JavaScript 1.2 form validation code for use on Netscape Navigator 4.x can write the code even more quickly by taking advantage of this new feature.
Regular expressions are a notation for describing sequences of characters.
The most popular and well-known notation for describing regular expressions in software is defined by the Perl scripting language. Perl has become popular because its support for regular expressions makes it easy to write scripts which process text files and change or sort their contents. To make it easy for developers to take advantage of this new functionality, JavaScript 1.2 supports the popular Perl syntax. Experienced Perl developers will find it easy to start using regular expressions in JavaScript, and developers new to regular expressions will be able to take advantage of the many tutorials already in existence on Perl and regular expressions. For a basic introduction to regular expressions and their use in JavaScript 1.2, read this View Source article on String Matching and Replacing in JavaScript 1.2 .