• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Regular Expressions and Patt... > What Is a Regular Expression?

13.1. What Is a Regular Expression?

A user is asked to fill out an HTML form and provide his name, address, and birth date. Before sending the form off to a server for further processing, a JavaScript program checks the form to make sure the user actually entered something, and that the information is in the requested format. We saw in the last chapter some basic ways that JavaScript can check form information, but now with the addition of regular expressions, form validation can be much more sophisticated and precise. Before getting into form validation, we will delve into regular expressions and how they work. If you are savvy with Perl regular expressions (or the UNIX utilities, grep, sed, and awk), you may move rapidly through this section, since JavaScript regular expressions, for the most part, are identical to those found in Perl.

A regular expression is really just a sequence or pattern of characters that is matched against a string of text when performing searches and replacements. A simple regular expression consists of a character or set of characters that matches itself. The regular expression is normally delimited by forward slashes; for example, /abc/.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint