Skip to Main Content
Coding with JavaScript For Dummies
book

Coding with JavaScript For Dummies

by Chris Minnick, Eva Holland
May 2015
Beginner content levelBeginner
360 pages
6h 39m
English
For Dummies
Content preview from Coding with JavaScript For Dummies

Chapter 14

Searching with Regular Expressions

In This Chapter

arrow Finding patterns with regular expressions

arrow Writing regular expressions

arrow Using regular expressions in JavaScript

Creating problems is easy. We do it all the time. Finding solutions, ones that last and produce good results, requires guts and care.

— Henry Rollins

Regular expressions are a powerful tool within many programming languages that help you find and change text within documents according to patterns within the text. The syntax for regular expressions can be intimidating at first, but once you get the hang of it, there will be nothing you can’t do with text.

Finding It Out with Regular Expressions

Regular expressions are a way to look for patterns or character combinations in strings.

Example uses for regular expressions include

  • Checking a user-entered email address to make sure that it’s in the right format
  • Finding and replacing all instances of a person’s name in an article
  • Locating capitalized words in the middle of sentences throughout a book
  • Finding strings of numbers that look like phone numbers inside a document

Here’s what a regular expression looks like:

^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$ ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

HTML5 Programming with JavaScript For Dummies

HTML5 Programming with JavaScript For Dummies

John Paul Mueller
JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland

Publisher Resources

ISBN: 9781119056072Purchase book