Cover by Marijn Haverbeke

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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 ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required