JavaScript Regular Expressions
eBook - ePub

JavaScript Regular Expressions

Loiane Groner, Gabriel Manricks

Condividi libro
  1. 112 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

JavaScript Regular Expressions

Loiane Groner, Gabriel Manricks

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
JavaScript Regular Expressions è disponibile online in formato PDF/ePub?
Sì, puoi accedere a JavaScript Regular Expressions di Loiane Groner, Gabriel Manricks in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Web Programming. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2015
ISBN
9781783282258

JavaScript Regular Expressions


Table of Contents

JavaScript Regular Expressions
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Regex
It's all about patterns
Analyzing a phone number
Analyzing a simple log file
Analyzing an XML file
Regex in JavaScript
The RegExp constructor
Using pattern flags
Using the rgx.test method
Using the rgx.exec method
The string object and regular expressions
Using the String.replace method
Using the String.search method
Using the String.match method
Building our environment
Handling a submitted form
Resetting matches and errors
Creating a regular expression
Executing RegExp and extracting its matches
Testing our application
Summary
2. The Basics
Defining vague matchers in Regex
Matching a wild card character
Matching digits
Matching alphanumeric chars
Negating alphanumeric chars and digits
Defining ranges in Regex
Defining a range
Matching the dash character
Defining negated ranges
Defining multipliers in Regex
Matching one or more occurrences
Matching zero or one occurrence
Matching zero or more occurrences
Defining custom quantifiers
Matching n or more occurrences
Matching n to m occurrences
Matching alternated options
Creating a Regex for a telephone number
Summary
3. Special Characters
Nonvisual constraints
Matching the beginning and end of an input
Matching word boundaries
Matching nonword boundaries
Matching a whitespace character
Defining nongreedy quantifiers
Matching groups in Regex
Grouping characters together to create a clause
Capture and noncapture groups
Matching non capture groups
Matching lookahead groups
Using a negative lookahead
Summary
4. Regex in Practice
Regular expressions and form validation
Setting up the form
Validating fields
Matching a complete name
Understanding the complete name Regex
Matching an e-mail with Regex
Understanding the e-mail Regex
Matching a Twitter name
Understanding the twitter username Regex
Matching passwords
Matching URLs
Understanding the URL Regex
Manipulating data
Using the String.replace method
Matching a description field
Understanding the description Regex
Explaining a Markdown example
Summary
5. Node.js and Regex
Setting up Node.js
Getting started with our application
Reading a file with Node.js
The anatomy of an Apache log file
Creating the Apache log Regex
Creating a Regex for the time part
Creating a Regex for the request information
Creating a Regex for the status code and object size
Creating a Regex for the referrer and the user agent
Parsing each Apache log row
Creating a JSON object for each row
Display the JSON in a table
Summary
A. JavaScript Regex Cheat Sheet
Character classes
Literals
Character sets
Boundaries
Grouping, alternation, and back reference
Quantifiers
JavaScript regular expressions methods
Index

JavaScript Regular Expressions

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2015
Production reference: 1250515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-225-8
www.packtpub.com

Credits

Authors
Loiane Groner
Gabriel Manricks
Reviewers
Andrea Barisone
Florian Bruniaux
Robert K Casto
Julio Freitas
Juri Strumpflohner
Commissioning Editor
Kunal Parikh
Acquisition Editor
Subho Gupta
Content Development Editor
Rohit Kumar Singh
Technical Editors
Bhupesh Kothari
Mrunmayee Patil
Copy Editor
Sonia Michelle Cheema
Project Coordinator
Mary Alex
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Sheetal Aute
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda

About the Authors

Loiane Groner has over 9 years of s...

Indice dei contenuti