O'Reilly logo

Eloquent JavaScript by Marijn Haverbeke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Regular Expressions

At various points in the previous chapters, we had to look for patterns in string values. In Chapter 3 we extracted date values from strings by writing out the precise positions at which the numbers that were part of the date could be found. Later, in Chapter 5, we saw some particularly ugly pieces of code for finding certain types of characters in a string, for example the characters that had to be escaped in HTML output.

Regular expressions are a language for describing patterns in string data. They form a small, separate language, which is embedded inside JavaScript (as well as various other programming languages). This language is very succinct, though not very readable—big regular expressions tend to look like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required