ebook img

Beginning Regular Expressions PDF

771 Pages·2005·24.355 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Beginning Regular Expressions

01_574892 ffirs.qxd 1/7/05 10:48 PM Page iii Beginning Regular Expressions Andrew Watt 01_574892 ffirs.qxd 1/7/05 10:48 PM Page ii 01_574892 ffirs.qxd 1/7/05 10:48 PM Page i Beginning Regular Expressions 01_574892 ffirs.qxd 1/7/05 10:48 PM Page ii 01_574892 ffirs.qxd 1/7/05 10:48 PM Page iii Beginning Regular Expressions Andrew Watt 01_574892 ffirs.qxd 1/7/05 10:48 PM Page iv Beginning Regular Expressions Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2005 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 0-7645-7489-2 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, e-mail: [email protected]. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP- RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACYOR COMPLETENESS OF THE CON- TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR APARTICULAR PURPOSE. NO WARRANTYMAYBE CREATED OR EXTENDED BYSALES OR PROMOTIONALMATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAYNOT BE SUITABLE FOR EVERYSITUATION. THIS WORK IS SOLD WITH THE UNDERSTAND- ING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PRO- FESSIONALSERVICES. IF PROFESSIONALASSISTANCE IS REQUIRED, THE SERVICES OF ACOMPETENT PROFESSIONALPERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALLBE LIABLE FOR DAMAGES ARISING HERE FROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS ACITATION AND/OR APOTENTIALSOURCE OF FURTHER INFORMA- TION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAYPROVIDE OR RECOMMENDATIONS IT MAYMAKE. FURTHER, READ- ERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAYHAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks:Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respec- tive owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data: Watt, Andrew, 1953- Beginning regular expressions / Andrew Watt. p. cm. ISBN 0-7645-7489-2 (paper/website) 1. Text processing (Computer science) I. Title. QA76.9.T48W37 2005 005.52—dc22 2004028308 01_574892 ffirs.qxd 1/7/05 10:48 PM Page v About the Author Andrew Watt is an independent consultant and experienced author with an interest and expertise in XMLand Web technologies. He has written and coauthored more than 10 books on Web development and XML, including XPath Essentials and XMLSchema Essentials. He has been programming since 1984, moving to Web development technologies in 1994. He’s a well-known voice in several influential online technical communities and is a frequent contributor to many Web development specifications. Dedication I would like to dedicate this book to the memory of my late father, George Alec Watt, a very special human being. Acknowledgments Authors often state that a book is the work of a team rather than a single person. There is a good reason for that assertion. It’s true. First, I would like to thank Jim Minatel, the acquisitions editor who put the platform in place to get Beginning Regular Expressionsoff the ground at Wrox/Wiley. His patience, under significant provocation relating to timetable, and his tact, efficiency, and general good nature made those organizational aspects of the book an enjoyable experience to repeat at a future date. The development editor, Marcia Ellett, was great to work with and did a lot to tidy up my prose to make a better read for all readers of this book. In addition, her eagle eyes spotted some minor slips that had slipped through the authorial net. Thanks, Marcia. Doug Steele, a fellow Microsoft MVP, was technical editor and carried out a tactful and painstaking job and picked up many little things that the smoke from the author’s midnight oil seemed somehow to obscure. Thanks, Doug. Darren Niemke, another MVP, helped with technical editing of a number of chapters. Thanks, Darren. My thanks go, too, to the production staff at Wiley who, as is typically the case, the author never meets. Without their efforts in translating a manuscript into a finished product this book would not exist in its current form. 01_574892 ffirs.qxd 1/7/05 10:48 PM Page vi Credits Acquisitions Editor Editorial Manager Jim Minatel Mary Beth Wakefield Development Editor Vice President & Executive Group Publisher Marcia Ellett Richard Swadley Technical Editors Vice President and Publisher Douglas J. Steele Joseph B. Wikert Darren Neimke Project Coordinator Production Editor April Farling Felicia Robinson Media Development Specialist Copy Editor Angie Denny Jeri Freedman/Foxxe Editorial Services vi 02_574892 ftoc.qxd 1/7/05 10:48 PM Page vii Contents Introduction xxi Who This Book Is For xxi What This Book Covers xxii How This Book Is Structured xxii What You Need to Use This Book xxiii Conventions xxiii Source Code xxiv Errata xxiv p2p.wrox.com xxv Chapter 1: Introduction to Regular Expressions 1 What Are Regular Expressions? 2 What Can Regular Expressions Be Used For? 5 Finding Doubled Words 5 Checking Input from Web Forms 5 Changing Date Formats 6 Finding Incorrect Case 6 Adding Links to URLs 6 Regular Expressions You Already Use 7 Search and Replace in Word Processors 7 Directory Listings 7 Online Searching 8 Why Regular Expressions Seem Intimidating 8 Compact,Cryptic Syntax 8 Whitespace Can Significantly Alter the Meaning 9 No Standards Body 12 Differences between Implementations 12 Characters Change Meaning in Different Contexts 13 Regular Expressions Can Be Case Sensitive 15 Case-Sensitive and Case-Insensitive Matching 15 Case and Metacharacters 16

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.